毎日モザイク

White Room Layout Works

2012-02-08T03:18:53+09:00 [Wed]

illustratorでindesignの一番左のボタンみたいなの。

illustratorにいっぱい画像を貼る作業があったので、こんなもん人間のやる作業じゃないだろw とか思って、indesignのフレームに均等に流し込むボタンみたいなプラグインは無いものか? と探してみましたが、見つからなかったので似たようなものをつくりました。

SyntaxHighliterPlusにApplescript用のテンプレートがないので色付けがおかしいですが、そのためにJSで書くのもなんなので(まぁ、ASのような早さでは書けないわけですがw)、JS用の色付けですみません。

□でも○でも☆でもなんでも、フレームに均等に流し込んでセンタリングします。

配置ファイルとクリッピングパスが一対一のものだけ対象。

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
tell application "Adobe Illustrator"
    tell document 1
        set grilst to group items whose selected = true
        repeat with ll in grilst
            if (count placed items of ll) = 1 then
                set {pir, plir} to {a reference to path item 1 of ll, a reference to placed item 1 of ll}
                set {w, h, {x, y}} to {width of pir, height of pir, position of pir}
                set {w2, h2} to {width of plir, height of plir}
                set {width of plir, height of plir} to {w, h2 * w / w2}
                if h > h2 * w / w2 then
                    set {width of plir, height of plir} to {w2 * h / h2, h}
                end if
                set {xdif, ydif} to {(w - (width of plir)) / 2, (h - (height of plir)) / 2}
                if xdif < 0 then set xdif to -xdif
                if ydif < 0 then set ydif to -ydif
                set position of plir to {x - xdif, y + ydif}
            end if
        end repeat
    end tell
end tell