Skip to content

Instantly share code, notes, and snippets.

@kanemu
Created July 26, 2012 01:44
Show Gist options
  • Save kanemu/3179784 to your computer and use it in GitHub Desktop.
Save kanemu/3179784 to your computer and use it in GitHub Desktop.
[illustrator][indesign]Illustartor→InDesign間でBridgeTalk
#target " Illustrator"
//InD風Boundsに変換するfunction
forIndBounds=function(bounds){
var h=app.activeDocument.height;
var ary=[
h-bounds[1],
bounds[0],
h-bounds[3],
bounds[2]
];
return ary;
};
//とりあえず拾ったgeometricBoundsを全部Aryにつっこむ。
var selObj = app.activeDocument.selection;
var ary = [];
for(var i=0;i<selObj.length;i++){
var aigb=forIndBounds(selObj[i].geometricBounds);
ary.push(aigb);
};
$.writeln(ary.toSource());
//BridgeTalk経由でfunctionと変数を渡す。
btFunc=function(app,func,arg){
var argObj="";
if(typeof(arg)=="string") {
argObj="\""+arg+"\"";
}else{
argObj=arg.toSource();
}
var bt=new BridgeTalk();
bt.target = app;
bt.body = "var func="+func.toString();
bt.body += "func("+argObj+");";
bt.send();
};
//arrayからテキストフレームを作る。
//とりあえず、InD側の単位はあらかじめ全部ポイントに合わせ、線幅や色も決めうち。
createTextFrame=function(objAry){
var docObj = app.activeDocument
for(var i=0;i<objAry.length;i++){
txtObj = docObj.textFrames.add();
txtObj.geometricBounds = objAry[i];
txtObj.strokeColor ="Black";
txtObj.strokeWeight = 10;
}
};
btFunc("InDesign",createTextFrame,ary);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment