Adobe Illustrator 用にオブジェクトの大きさを揃えるスクリプトを公開しました.
Adobe Illustorator 用の選択したオブジェクトの大きさを揃えるスクリプトです.レーザーカットの時に穴の大きさをまとめて変えたくて作りました.https://t.co/AwkMyolUH6
昔書いたまま化石になっていたのを公開しました pic.twitter.com/9Db48mplMA— botamochi (@botamochi6277) October 9, 2021
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// script aligning the size of objects with each object origins (center) | |
// use case: change hole sizes | |
var dia = new Window("dialog", "unitize object scale", [0, 0, 250, 400]); | |
dia.pane1 = dia.add("panel", [5, 25, 240, 300], "refelence length"); | |
dia.radi1 = dia.pane1.add("radiobutton", [10, 10, 170, 30], "max. height"); | |
dia.radi2 = dia.pane1.add("radiobutton", [10, 35, 170, 55], "max. width"); | |
dia.radi3 = dia.pane1.add("radiobutton", [10, 60, 170, 80], "min. height"); | |
dia.radi4 = dia.pane1.add("radiobutton", [10, 85, 170, 105], "min. width"); | |
dia.bot1 = dia.add("button", [10, 360, 240, 390], "Run", { name: "ok" }); | |
dia.radi1.value = true;// initial selected radio button | |
dia.center(); | |
dia.show(); | |
sel = activeDocument.selection; | |
var heightMax = 0; // temporary maximum of height | |
var widthMax = 0;// temporary maximum of width | |
var heightMin = 1e9;// temporary minimum of height | |
var widthMin = 1e9;// temporary minimum of width | |
var selSize = []; | |
// get maximum and minimum lengths | |
for (i = 0; i < sel.length; i++) { | |
if (sel[i].clipped) { | |
selSize[i] = sel[i].pageItems[0]; | |
} else { | |
selSize[i] = sel[i]; | |
} | |
// update maximum and minimum lengths | |
if (heightMax < selSize[i].height) { heightMax = selSize[i].height } | |
if (widthMax < selSize[i].width) { widthMax = selSize[i].width } | |
if (heightMin > selSize[i].height) { heightMin = selSize[i].height } | |
if (widthMin > selSize[i].width) { widthMin = selSize[i].width } | |
} | |
// scale object sizes | |
for (i = 0; i < sel.length; i++) { | |
if (dia.radi1.value) { | |
scale = heightMax / selSize[i].height * 100; | |
} else if (dia.radi2.value) { | |
scale = widthMax / selSize[i].width * 100; | |
} else if (dia.radi3.value) { | |
scale = heightMin / selSize[i].height * 100; | |
} else { | |
scale = widthMin / selSize[i].width * 100; | |
} | |
sel[i].resize(scale, scale, true, true, true, true, scale, Transformation.CENTER); | |
} |
使い方:
- 大きさを変えたい揃えたいオブジェクトを選択する
- スクリプトを実行する
- ウィンドウが出てくるので,縦横/最大最小のどれに合わせるのか選択して実行する
- 選択したオブジェクトの大きさが変わる
コメント