Passing a variable from Photoshop to Illustrator
alright, i've been on here lot last couple weeks trying figure out bridgetalk, , starting hang of it. writing illustrator script open specified template , grab photoshop's active document , place on template. have working 1 hiccup. script goes photoshop, grabs filepath, opens illustrator doc, , places file perfectly. takes 2 runs through script work. it's weirdest thing. if run script when ps first opens, gives me error; if run again works perfectly, if close ps doc , open new one, run script, places previous document!
i stumped , have tried can think of. here simplified version of part of script produces error. first time run script, "alert(psfile)" wrong, when run again works perfectly.
#target illustrator var psfile; infofromps (); var illtemp = file("/users/art1/desktop/template.ai"); app.open(illtemp); var doc = app.activedocument; function infofromps() { var bt = new bridgetalk; bt.target = "photoshop"; bt.body = "app.activedocument.fullname;" bt.onresult = function(resobj) { var myresult = resobj.body; psfile = file(myresult); } bt.send(); } alert(psfile);
this simplified version simplified not connecting illustrator photoshop in way able tell...but in case, script not waiting result, keeps going after send it, that's why error first time, after previous result
it goes first time
var psfile; // undefined infofromps (); // i'm not waiting bridgetalk fetch me result alert(psfile); // psfile undefined, //...bridgetalk returns result after you're done psfile = 'some file';
second time, or after change ps activedocument
var psfile; // still have in memory result previous run ('some file') infofromps (); // i'm still not waiting result alert(psfile); // psfile 'some file' previous run, //...bridgetalk returns result after you're done psfile = 'some other file';
More discussions in Illustrator Scripting
adobe
Comments
Post a Comment