選択したものを入力値に合わせて縦横比固定で拡大縮小します。
↓変形のいろいろ
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#TransformationMatrices.html
↓基準点のいろいろ
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#AnchorPoint.html
//幅で合わす function main(){ var sel=app.activeDocument.selection, WS=prompt ("幅","30"); for(var i=0; i<sel.length; i++){ var selGB=sel[i].geometricBounds, selW=selGB[3]-selGB[1], selSc=WS/selW, myW=app.transformationMatrices.add({horizontalScaleFactor:selSc, verticalScaleFactor:selSc}) sel[i].transform(CoordinateSpaces.pasteboardCoordinates, AnchorPoint.BOTTOM_CENTER_ANCHOR, myW);//底中央基点 } }app.doScript(main, ScriptLanguage.JAVASCRIPT, [], UndoModes.FAST_ENTIRE_SCRIPT);
//高さで合わす function main(){ var sel=app.activeDocument.selection, HS=prompt ("高さ","50"); for(var i=0; i<sel.length; i++){ var selGB=sel[i].geometricBounds, selH=selGB[2]-selGB[0], selSc=HS/selH, myH = app.transformationMatrices.add({horizontalScaleFactor:selSc, verticalScaleFactor:selSc}) sel[i].transform(CoordinateSpaces.pasteboardCoordinates, AnchorPoint.BOTTOM_CENTER_ANCHOR, myH); } }app.doScript(main, ScriptLanguage.JAVASCRIPT, [], UndoModes.FAST_ENTIRE_SCRIPT);