var myDocument = app.activeDocument; if (myDocument.selection[0] instanceof TextFrame && myDocument.selection[1] instanceof TextFrame) { var tf1, tf2; // 左Xを比較してどちらが左(tf1)かを決定 if (myDocument.selection[0].visibleBounds[1] < myDocument.selection[1].visibleBounds[1]) { tf1 = myDocument.selection[0]; tf2 = myDocument.selection[1]; } else { tf1 = myDocument.selection[1]; tf2 = myDocument.selection[0]; } // 単位バックアップ var backunit = [myDocument.viewPreferences.horizontalMeasurementUnits, myDocument.viewPreferences.verticalMeasurementUnits]; myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.MILLIMETERS; myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.MILLIMETERS; var tf1g = tf1.visibleBounds; // geometricBoundsだと線が含まれない var tf2g = tf2.visibleBounds; tf1g[1] += 10; tf1g[3] += 10; tf1.geometricBounds = tf1g; // ここからはもう1つの課題 // 「右にあるフレームを左のフレームから3mm離した場所に置く、と想定。 var w = tf2g[3] - tf2g[1]; tf2g[1] = tf1g[3] + 3; tf2g[3] = tf2g[1] + w; tf2.visibleBounds = tf2g; // 単位を戻す myDocument.viewPreferences.horizontalMeasurementUnits = backunit[0]; myDocument.viewPreferences.verticalMeasurementUnits = backunit[1]; } else { alert("対象テキストフレームを2つ選択してください。"); }