A while back I made a post bb/viewtopic.php?f=9&t=4631 about a problem I was having with using BridgeTalk in a loop.
Now I am having trouble again. I think the problem both times was I can't get Illustrator to return an onResult message. The call always times out. Has anyone else had this problem?
I don't have this issue when sending messages to Bridge or InDesign.
edit: From the tools guideNOTE: The message callbacks are optional, and are not implemented by all message-enabled applications.I guess it is too much trouble for them to tell us which ones don't support callbacks.
BridgeTalk with Photoshop and Illustrator
BridgeTalk with Photoshop and Illustrator
Mike, Im not having a problem with getting an onResult() or at least I don't think so… Bridgetalk is not my favourite part of the toolkit and I kind of muddle my way with it… Anyhows this would apper to work just fine for me…
Code: Select all#target photoshop
var aiScript = doAI;
btOpen( 'illustrator', aiScript );
//
function btOpen( targetApp, script ) {
var bt = new BridgeTalk();
bt.target = targetApp;
bt.body = script + 'doAI();';
bt.onResult = function( inBT ) { $.writeln( inBT.body ) };
//bt.onError = function( inBT ) { $.writeln( inBT.body ) };
//bt.onTimeout = function( inBT ) { $.writeln( inBT.body ) };
bt.send( 10 );
};
function doAI() {
var f = File( Folder.desktop + '/Layers.ai' ); // I know this exists
app.open( f );
return app.activeDocument.name;
};
Just seen your PM so I will take a read of what you want but it looks a simple enough task…
Code: Select all#target photoshop
var aiScript = doAI;
btOpen( 'illustrator', aiScript );
//
function btOpen( targetApp, script ) {
var bt = new BridgeTalk();
bt.target = targetApp;
bt.body = script + 'doAI();';
bt.onResult = function( inBT ) { $.writeln( inBT.body ) };
//bt.onError = function( inBT ) { $.writeln( inBT.body ) };
//bt.onTimeout = function( inBT ) { $.writeln( inBT.body ) };
bt.send( 10 );
};
function doAI() {
var f = File( Folder.desktop + '/Layers.ai' ); // I know this exists
app.open( f );
return app.activeDocument.name;
};
Just seen your PM so I will take a read of what you want but it looks a simple enough task…
BridgeTalk with Photoshop and Illustrator
Mike, this should give you the basic idea… If you need any more just post back… AI will want to resize on percentage values you can see where I hard valued six inches…
Code: Select all#target photoshop
var aiScript = doAI;
btOpen( 'illustrator', aiScript );
//
function btOpen( targetApp, script ) {
var bt = new BridgeTalk();
bt.target = targetApp;
bt.body = script + 'doAI();';
bt.onResult = function( inBT ) { $.writeln( inBT.body ) };
//bt.onError = function( inBT ) { $.writeln( inBT.body ) };
//bt.onTimeout = function( inBT ) { $.writeln( inBT.body ) };
bt.send( 10 );
};
function doAI() {
var f, doc, grp, grpW, grpH, scale;
f = File( Folder.desktop + '/Layers.ai' );
app.open( f );
doc = app.activeDocument;
grp = doc.groupItems[0];
grpW = grp.visibleBounds[2] - grp.visibleBounds[0];
grpH = - ( grp.visibleBounds[3] - grp.visibleBounds[1] ); // AI is negitive down CS5 & CS6
if ( grpW >= grpH ) {
scale = ( 432 / grpW ) * 100; // Fit to Six Inch
} else {
scale = ( 432 / grpH ) * 100; // Fit to Six Inch
};
grp.resize( scale, scale, true, true, true, true, scale ); // Percent scale…
doc.artboards[0].artboardRect = doc.visibleBounds; // Change the artboard size to art
doc.close( SaveOptions.SAVECHANGES );
return true;
};
Code: Select all#target photoshop
var aiScript = doAI;
btOpen( 'illustrator', aiScript );
//
function btOpen( targetApp, script ) {
var bt = new BridgeTalk();
bt.target = targetApp;
bt.body = script + 'doAI();';
bt.onResult = function( inBT ) { $.writeln( inBT.body ) };
//bt.onError = function( inBT ) { $.writeln( inBT.body ) };
//bt.onTimeout = function( inBT ) { $.writeln( inBT.body ) };
bt.send( 10 );
};
function doAI() {
var f, doc, grp, grpW, grpH, scale;
f = File( Folder.desktop + '/Layers.ai' );
app.open( f );
doc = app.activeDocument;
grp = doc.groupItems[0];
grpW = grp.visibleBounds[2] - grp.visibleBounds[0];
grpH = - ( grp.visibleBounds[3] - grp.visibleBounds[1] ); // AI is negitive down CS5 & CS6
if ( grpW >= grpH ) {
scale = ( 432 / grpW ) * 100; // Fit to Six Inch
} else {
scale = ( 432 / grpH ) * 100; // Fit to Six Inch
};
grp.resize( scale, scale, true, true, true, true, scale ); // Percent scale…
doc.artboards[0].artboardRect = doc.visibleBounds; // Change the artboard size to art
doc.close( SaveOptions.SAVECHANGES );
return true;
};
BridgeTalk with Photoshop and Illustrator
larsen67 wrote:...but it looks a simple enough task…
Yes, it does look simple now. I guess the hard part is understanding the differences between the PS and AI DOMs.
I also don't seem to have a problem with getting a callback with simple tests messages or your short example. It is when I am trying to do more I seem to run into trouble. It's like if the task takes enough time Illustrator 'forgets' to send the results.
I have already spent more time on this than I thought I would so I just split the task into two parts. Run an AI script as a processor to a second Photoshop script. Could be that BridgeTalk was not design for doing more than short tasks or passing info between apps.
It could be that my limited experience working with other Adobe apps means I am going about this the wrong way.
Thanks for your examples, they help me now and I'm sure they will be helpful when I need them again.
Mike
Yes, it does look simple now. I guess the hard part is understanding the differences between the PS and AI DOMs.
I also don't seem to have a problem with getting a callback with simple tests messages or your short example. It is when I am trying to do more I seem to run into trouble. It's like if the task takes enough time Illustrator 'forgets' to send the results.
I have already spent more time on this than I thought I would so I just split the task into two parts. Run an AI script as a processor to a second Photoshop script. Could be that BridgeTalk was not design for doing more than short tasks or passing info between apps.
It could be that my limited experience working with other Adobe apps means I am going about this the wrong way.
Thanks for your examples, they help me now and I'm sure they will be helpful when I need them again.
Mike