JS / CS2 loading files selected in Bridge

General Discussion of Scripting for Adobe Bridge

Moderators: Tom, Kukurykus

rstucky

JS / CS2 loading files selected in Bridge

Post by rstucky »

From where I sit, that should have worked....

But it doesn't.

The executeScript uses eval( script.toSource() );

and toSource wraps strings in double quotes - not a rigorous implementation at all - but anyway... to have a chance of working, that script needed to be

photoshop.executeScript( "alert( 'hi' );" );

toSource makes that new String( "alert( 'hi' );" )

regardless, it doesn't work for me either.

Something must be messed up there, not sure what. I can't even get reliable access to ESTK's debugger in PS's scripting engine when trying to debug it. I'm going to file a bug on it.

The workflow in bridge is standard interface spec - select files, select menu to act on files. From where I sit, I'd much rather run as many automated functions as possible from Bridge, but that's me.

I see your point about having many scripts, some really big, and not wanting to convert them to bridge scripts.

I think what's called for is a Photoshop Script Runner....

It would search the PS scripts folder, making the scripts available in a palette. Do the selection thing, execute the script from the palette, and viola...

If the scripts just execute on the open front-most document, then they could be executed a number of ways.

The easiest would be to insert some code that opens the file at the front of the script - then eval it.

I don't know enough about how PS scripts are done to know exactly how to do it.
Andrew

JS / CS2 loading files selected in Bridge

Post by Andrew »

Well I'm making slow progress. I can run scripts from Bridge in PS, and pass variables to them from Bridge, using your openClose script structure (can't say I fully understand it yet but never mind). Is there a tighter way of doing this - like a bare-bones executeScript that actually works - or is that a good approach anyway.

Second issue - I would still really like to be able to send a request off from a PS script that gets me the list of files selected in Bridge (if there happen to be any). If I understand you right the problem is that Bridge will execute the request but it will not return the files info. How about Bridge writes the files info to an external file which the PS script can then read - it does not have to send anything back. I can handle the timing issues I think.

So the PS script does:

1. is Bridge open, if not forget it.

2. If open, send Bridge script that writes the list of selected files to a dat file.

3. If needed reads the dat file after the user has finished with the initial UI dialog in the PS script.

Any barebones help with how to request Bridge run a script (maybe I can reverse your openClose) much appreciated. In fact your help above is much appreciated anyway, thanks!

Andrew

Afterthought: If I've got the right idea on event handling I might even be able to make Bridge write the list of current selected files to an external dat file every time the selection changes - that would be an interesting tool for other scripts to access - even when Bridge is not open.
Andrew

JS / CS2 loading files selected in Bridge

Post by Andrew »

Got there - I start a script from PS. It sends a request to Bridge which writes a list of selected files to a data file and the PS script reads the list. I posted the code in a separate thread:

bb/viewtopic.php?t=175

So you can go Bridge >> PS and also PS >> Bridge >> PS transferring data all the way.

Andrew