I was wondering if anyone has seen the following problem:
On CS6 and Windows machines, there seems to be a bug in BridgeTalk. In order for Bridge to invoke Photoshop, the same script must be installed for both 32- and 64-bit versions of Photoshop and Bridge. In other words, the scripts must be installed in the following folders (actual names may vary):
/c/Program/Adobe/Adobe Photoshop CS6(64 bit)/Presets/Scripts/
/c/Program/Adobe/Adobe Photoshop CS6/Presets/Scripts/
/c/Program Files (x86)/Common Files/Adobe/Startup Scripts CS6/Adobe Bridge/
/c/Program Files/Common Files/Adobe/Startup Scripts CS6/Adobe Bridge/
Here is a sample script if anyone wants to try it out. Perhaps I have misunderstood something, but this code works fine in CS5.
(I'm not sure about the lines marked <--- ???)
This script does a multi-place, i.e., you can select several files in Bridge and Place them all at the same time, on top of the current Photoshop document.
As usual, I'd be very grateful for any help! Thanks.
Code: Select all
placefile = function(fileref, siz) {
cID = function(s) { return null; };
var desc18 = new ActionDescriptor();
desc18.putPath( charIDToTypeID('null'), fileref );
desc18.putEnumerated( charIDToTypeID('FTcs'), charIDToTypeID('QCSt'), charIDToTypeID('Qcsa') );
var desc19 = new ActionDescriptor();
desc19.putUnitDouble( charIDToTypeID('Hrzn'), charIDToTypeID('#Pxl'), siz );
desc19.putUnitDouble( charIDToTypeID('Vrtc'), charIDToTypeID('#Pxl'), siz );
desc18.putObject( charIDToTypeID('Ofst'), charIDToTypeID('Ofst'), desc19 );
executeAction( charIDToTypeID('Plc '), desc18, DialogModes.NO );
};
centerlayer = function() {
var rulerunits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var doc = app.activeDocument;
var x1 = doc.activeLayer.bounds[0]; var y1 = doc.activeLayer.bounds[1];
var x2 = doc.activeLayer.bounds[2]; var y2 = doc.activeLayer.bounds[3];
var cx = (x1+x2)/2; var cy = (y1+y2)/2;
var w = doc.width; var h = doc.height;
var orgres = doc.resolution;
var resampleMethod = ResampleMethod.NONE;
doc.resizeImage(null, null, 72, resampleMethod);
doc.activeLayer.translate(w/2 - cx, h/2 - cy);
doc.resizeImage(null, null, orgres, resampleMethod);
app.preferences.rulerUnits = rulerunits;
};
placeimg = function(img) {
placefile(img, Math.min(app.activeDocument.width, app.activeDocument.height));
};
multiplace = function(images) {
try {
if (BridgeTalk.appName == "bridge") {
var btMessage = new BridgeTalk;
btMessage.target = "photoshop"; // <---- ???
btMessage.body = "multiplace(" + images.toSource() + ")";
btMessage.send();
} else {
var targetApp = BridgeTalk.getSpecifier("photoshop"); // <---- ???
BridgeTalk.bringToFront(targetApp);
if (images == undefined || images.length == undefined || images.length == 0)
return;
if (app.documents.length == 0)
return alert("No document to place on!");
if (app.activeDocument.layers) /* select topmost layer */
app.activeDocument.activeLayer = app.activeDocument.layers[0];
for (var i = 0; i < images.length; i++) {
placeimg(images);
centerlayer();
}
}
} catch (e) {
alert(e);
}
};
if (BridgeTalk.appName == "bridge") {
if (MenuElement.find("multiplace") == null) {
var mpcmd = new MenuElement("command", "MultiPlace", "at the end of Thumbnail", "multiplace");
addimg = function(m) {
if (app.document.selections.length == 0)
return;
images = new Array();
var i, j = 0;
for (i = 0; i < app.document.selections.length; i++) {
if (app.document.selections.container)
continue;
images[j++] = new File(app.document.selections.path);
}
return images;
}
mpcmd.onSelect = function(m) {
try {
var images = addimg(m);
multiplace(images);
} catch (e) {
alert(e);
}
};
mpcmd.onDisplay = function(m) {
try {
var tn = app.document.selections[0];
if (tn.container) {
m.enabled = false;
} else {
m.enabled = true;
}
} catch(error) {
// Window.alert(error);
}
};
}
}
CS6 Windows problem with BridgeTalk
-
Paul MR
CS6 Windows problem with BridgeTalk
I don't seem to have this problem, but I don't use global functions that are available to all CS apps.
My preferences is to use the startup folder that can be opened from the Bridge Preferences - Startup Scripts - then use the button to open the folder.
It does mean you need to send your code via BridgeTalk though.
My preferences is to use the startup folder that can be opened from the Bridge Preferences - Startup Scripts - then use the button to open the folder.
It does mean you need to send your code via BridgeTalk though.
-
Mike Hale
CS6 Windows problem with BridgeTalk
I could be wrong but I think it has been that way on Windows since CS4. It's my understanding that on Windows 64bit systems Photoshop installs a 32 and 64 bit version and if you want a plug-in( which your script is acting like ) to be available in both versions you have to install in both. I think Adobe did that because there are some Windows version of third party plug-in that are 32bit only.
I also understand that when Mac switch to 64bit( CS5? ) it only installs as 64bit because Apple forced Mac developers to use 64bit. You can run a 32bit program on Mac but you have to take extra steps.
I also understand that when Mac switch to 64bit( CS5? ) it only installs as 64bit because Apple forced Mac developers to use 64bit. You can run a 32bit program on Mac but you have to take extra steps.
-
Paul MR
CS6 Windows problem with BridgeTalk
As an example this code will work with the opened latest version you have installed.
In other words you could have the 32bit or the 64 bit Photoshop open, and only have one script.
(All the script does is open the selected files as SOs)
I have also tested the code with setting bt.target = "photoshop"; to bt.target = "photoshop-12";
with no Photoshop open, it will then open Photoshop CS5 (instead of CS6) and the code still works.
Code: Select all#target bridge
if( BridgeTalk.appName == "bridge" ) {
PlaceSOFiles = new MenuElement("command", "Open Files as SO In Photoshop", "at the end of tools/ps");
PlaceSOFiles.onSelect = function () {
placeSOFilesInPhotoshop();
};
function placeSOFilesInPhotoshop(){
var sels = app.document.selections;
for (i = 0; i < sels.length; i++) {
var t = new Thumbnail(sels);
sendPicToPhotoshop(sels.spec);
}
};
function sendPicToPhotoshop(fileName) {
function _placeFile(fileName) {
open(fileName,undefined,true);
};
var bt = new BridgeTalk;
bt.target = "photoshop";
var myScript = ("var SOs = " + _placeFile.toSource() + "; SOs(" + fileName.toSource() +");");
bt.body = myScript;
bt.send();
};
};
In other words you could have the 32bit or the 64 bit Photoshop open, and only have one script.
(All the script does is open the selected files as SOs)
I have also tested the code with setting bt.target = "photoshop"; to bt.target = "photoshop-12";
with no Photoshop open, it will then open Photoshop CS5 (instead of CS6) and the code still works.
Code: Select all#target bridge
if( BridgeTalk.appName == "bridge" ) {
PlaceSOFiles = new MenuElement("command", "Open Files as SO In Photoshop", "at the end of tools/ps");
PlaceSOFiles.onSelect = function () {
placeSOFilesInPhotoshop();
};
function placeSOFilesInPhotoshop(){
var sels = app.document.selections;
for (i = 0; i < sels.length; i++) {
var t = new Thumbnail(sels);
sendPicToPhotoshop(sels.spec);
}
};
function sendPicToPhotoshop(fileName) {
function _placeFile(fileName) {
open(fileName,undefined,true);
};
var bt = new BridgeTalk;
bt.target = "photoshop";
var myScript = ("var SOs = " + _placeFile.toSource() + "; SOs(" + fileName.toSource() +");");
bt.body = myScript;
bt.send();
};
};
-
kpt
CS6 Windows problem with BridgeTalk
Paul, does your script work because you are "only" doing this?
Code: Select allfunction _placeFile(fileName) {
open(fileName,undefined,true);
};
I tried to do something more elaborate with fileName, like place:ing it on a document, transforming that layer, etc, but it doesn't work.
My understanding of the Photoshop/Bridge communication is that the same script needs to be in both these folders:
[Photoshop] /c/Program/Adobe/Adobe Photoshop CS6/Presets/Scripts/
[Bridge] /c/Program Files/Common Files/Adobe/Startup Scripts CS6/Adobe Bridge/
If I try put the Bridge script in %APPDATA%\Adobe\StartupScripts, the BridgeTalkin' doesn't work.
Code: Select allfunction _placeFile(fileName) {
open(fileName,undefined,true);
};
I tried to do something more elaborate with fileName, like place:ing it on a document, transforming that layer, etc, but it doesn't work.
My understanding of the Photoshop/Bridge communication is that the same script needs to be in both these folders:
[Photoshop] /c/Program/Adobe/Adobe Photoshop CS6/Presets/Scripts/
[Bridge] /c/Program Files/Common Files/Adobe/Startup Scripts CS6/Adobe Bridge/
If I try put the Bridge script in %APPDATA%\Adobe\StartupScripts, the BridgeTalkin' doesn't work.
-
Paul MR
CS6 Windows problem with BridgeTalk
Yes, I only have the script in the one folder...
C:\Users\[User Name]\AppData\Roaming\Adobe\Bridge CS6\Startup Scripts
Yes it is only a one line script to open the selected documents as SOs and it works fine.
C:\Users\[User Name]\AppData\Roaming\Adobe\Bridge CS6\Startup Scripts
Yes it is only a one line script to open the selected documents as SOs and it works fine.
-
kpt
CS6 Windows problem with BridgeTalk
Paul, a big thank you! It has taken me a while to experiment with this but this is definitely the better way to go: no need for admin privileges and avoiding the 32/64-bit bug in Windows. (I can now also verify that this works in CS6 on Windows.)
So, the string that is passed in bt.body has no access to functions in the rest of the script, and therefore functions that needs to be called from bt.body''s string must be included in the string as well. These strings can be really long but it seems to work.
For instance, if you were to do
Code: Select allfunction _placeFile(fileName) {
foo(42);
open(fileName,undefined,true);
};
then the definition of foo must appear in bt.body, e.g., by defining foo inside _placeFile.
The only thing that is not working right now is regular expressions, but I am trying a work-around.
On a side note, the script folder, which is
Mac: ~/Library/Application Support/Adobe/Bridge CS5.1/Startup Scripts
Windows: C:\Users\[User Name]\AppData\Roaming\Adobe\Bridge CS6\Startup Scripts
can be accessed via the following code
Code: Select allvar x = decodeURI(Folder.startup).match(/CS\d+\.?\d*/);
var StartUpScripts = Folder(Folder.userData + "/Adobe/Bridge " + x + "/Startup Scripts");
Note: the last folder, "Startup Scripts" may not exist and therefore has to be created!
PS: I just made a $20 donation to the forum. Paul, let me know if you have a donation fund as well
So, the string that is passed in bt.body has no access to functions in the rest of the script, and therefore functions that needs to be called from bt.body''s string must be included in the string as well. These strings can be really long but it seems to work.
For instance, if you were to do
Code: Select allfunction _placeFile(fileName) {
foo(42);
open(fileName,undefined,true);
};
then the definition of foo must appear in bt.body, e.g., by defining foo inside _placeFile.
The only thing that is not working right now is regular expressions, but I am trying a work-around.
On a side note, the script folder, which is
Mac: ~/Library/Application Support/Adobe/Bridge CS5.1/Startup Scripts
Windows: C:\Users\[User Name]\AppData\Roaming\Adobe\Bridge CS6\Startup Scripts
can be accessed via the following code
Code: Select allvar x = decodeURI(Folder.startup).match(/CS\d+\.?\d*/);
var StartUpScripts = Folder(Folder.userData + "/Adobe/Bridge " + x + "/Startup Scripts");
Note: the last folder, "Startup Scripts" may not exist and therefore has to be created!
PS: I just made a $20 donation to the forum. Paul, let me know if you have a donation fund as well
-
Paul MR
CS6 Windows problem with BridgeTalk
Yes certain characters need to be escaped as an example...
Code: Select all//Test for regex, run from ESTK
//needs to have a document open in Photoshop
function script(){
try{
alert("Got here");
/* you need to escape backslash etc */
/* N.B coments must be like this! */
var Name = app.activeDocument.name.replace(/\\.[^\\.]+$/, '');
alert(Name);
}catch(e){alert(e);}
}
var bt = new BridgeTalk;
bt.target = "photoshop";
bt.body = "var ftn = " + script.toSource() + "; ftn();";
bt.send();
Thank you for supporting this site!
Code: Select all//Test for regex, run from ESTK
//needs to have a document open in Photoshop
function script(){
try{
alert("Got here");
/* you need to escape backslash etc */
/* N.B coments must be like this! */
var Name = app.activeDocument.name.replace(/\\.[^\\.]+$/, '');
alert(Name);
}catch(e){alert(e);}
}
var bt = new BridgeTalk;
bt.target = "photoshop";
bt.body = "var ftn = " + script.toSource() + "; ftn();";
bt.send();
Thank you for supporting this site!
-
kpt
CS6 Windows problem with BridgeTalk
Hehe, just realized the escape problem 10 minutes ago! I thought there was a problem with the /.../ notation first, so I switched to new RegExp().
Have a nice Sunday Paul, greetings from Cornwall.
Have a nice Sunday Paul, greetings from Cornwall.
-
Mike Hale
CS6 Windows problem with BridgeTalk
I also wanted to say thanks for supporting the site. The hosting account is up for renewal the first of next month and donations are used to offset the cost of running the site.