イラストレーターのテキストフレームをインデザインのテキストフレームにコンバート

イラストレターで選択しているテキストフレームを
インデザインにコンバートします。
一文字ずつ処理しているので文字数が多いものには向きません。
参照するのは位置、フォント、サイズ、トラッキング、縦組・横組のみなので完璧なものではないですが、補助系として使うと便利です。
//2009-07-22 インデザイン側を一旦ポイントにした単位系を元に戻す様にちょいと修正。
(function(){
#include 'c.js';
#target 'illustrator';
c('S').filter('T').each(function(){
var gb = [app.activeDocument.height-this.geometricBounds[1],this.geometricBounds[0],app.activeDocument.height-this.geometricBounds[3],this.geometricBounds[2]];
var kumi = this.orientation == TextOrientation.HORIZONTAL ? 'yokokumi' : 'tatekumi';
var contents = [];
c(this.textRanges).each(function(){
contents.push({
'contents' : this.contents == String.fromCharCode(13) ? '[RETURN]' : this.contents ,
'font' : this.textFont.family +' '+this.textFont.style,
'size' : this.size,
'leading' : this.leading,
'hs' : this.horizontalScale,
'vs' : this.verticalScale,
'tracking' : this.tracking
});
});
//BridgeTalk;
var bt=new BridgeTalk();
bt.target = 'indesign';
bt.body = toInDesign.toSource()+"("+contents.toSource()+","+gb.toSource()+","+kumi.toSource()+");";
bt.onResult = function(resObj) {};
bt.onError = function(e){$.writeln(e.body);};
bt.send(100);
});
function toInDesign(textobj,gb,kumi){
var backupviewPreferences = {
'horizontalMeasurementUnits' : app.activeDocument.viewPreferences.horizontalMeasurementUnits,
'verticalMeasurementUnits' : app.activeDocument.viewPreferences.verticalMeasurementUnits,
'textSizeMeasurementUnits' : app.activeDocument.viewPreferences.textSizeMeasurementUnits,
'typographicMeasurementUnits' : app.activeDocument.viewPreferences.typographicMeasurementUnits,
};
with(app.activeDocument.viewPreferences){
horizontalMeasurementUnits = verticalMeasurementUnits = textSizeMeasurementUnits = typographicMeasurementUnits = MeasurementUnits.points;
};
var textobj = eval(textobj);
var kumi = eval(kumi);
var TF = app.activeDocument.textFrames.add();
if(kumi == 'yokokumi'){
TF.parentStory.storyPreferences.storyOrientation = 1752134266;
}else{
TF.parentStory.storyPreferences.storyOrientation = 1986359924;
}
TF.geometricBounds = [gb[0],gb[1],gb[2]+20,gb[3]+20];
for(i =0;i < textobj.length;i++){
TF.contents += textobj[i].contents;
with(TF.characters[i].textStyleRanges[0]){
pointSize = UnitValue(textobj[i].size+'pt').as('pt');
appliedFont = app.fonts.item(textobj[i].font);
tracking = textobj[i].tracking;
horizontalScale = textobj[i].hs;
verticalScale = textobj[i].vs;
leading = textobj[i].leading;
}
}
app.findGrepPreferences = app.changeGrepPreferences =NothingEnum.nothing;
app.findChangeGrepOptions.includeLockedLayersForFind = false;
app.findChangeGrepOptions.includeLockedStoriesForFind = false;
app.findChangeGrepOptions.includeHiddenLayers = false;
app.findChangeGrepOptions.includeMasterPages = false;
app.findChangeGrepOptions.includeFootnotes = false;
app.findChangeGrepOptions.kanaSensitive = true;
app.findChangeGrepOptions.widthSensitive = true;
app.findGrepPreferences.findWhat = '\[RETURN\]';
app.changeGrepPreferences.changeTo = '\r';
var findRETURN = TF.changeGrep(true);
with(app.activeDocument.viewPreferences){
horizontalMeasurementUnits = backupviewPreferences.horizontalMeasurementUnits;
verticalMeasurementUnits = backupviewPreferences.verticalMeasurementUnits;
textSizeMeasurementUnits = backupviewPreferences.textSizeMeasurementUnits;
typographicMeasurementUnits = backupviewPreferences.typographicMeasurementUnits;
}
}
})();このスクリプトを作るにあたり、c.jsも書き直しております。
ObjectとArrayへの汚染をしないように書き直しました。