Illustratorとけっこう違う部分があります。ラインの作成、カラーの指定、グループの作り方などさまざまなスクリプト勉強になります。
global lineW, mypt, myCol --グローバル変数の宣言。線幅とポイント数、色はグローバルにした set lineW to 0.1 --線幅0.1 set mypt to 2.83 --ポイントは2.83 tell application "Adobe InDesign CS2_J" tell active document set selectedItems to selection --選択アイテムを調べる if selectedItems is {} then --選択アイテムが無ければ display dialog "フレームを1つだけ選択してください。" return end if if not (exists (layers whose name is "TOMBO")) then --トンボレイヤーがなければ make layer with properties {name:"TOMBO"}--レイヤーを作る end if set myCol to color "Registration" -- 変数myColはレジストレーションにしておく if number of selectedItems is 1 then --選択アイテムが1つなら set selItem to item 1 of selectedItems --選択アイテムの1つめを取り出す。(変数selectedItemsはリストだから) set myParent to parent of selItem --選択アイテムの親オブジェクトを調べる。 --(ページ番号が入ると思われる。) --※こまかいエラー処理をしていないのはご容赦 set myBounds to geometric bounds of selItem --選択アイテムの領域 set X to item 2 of myBounds--X座標 set Y to item 1 of myBounds--Y座標 set W to (item 4 of myBounds) - (item 2 of myBounds)--幅 set H to (item 3 of myBounds) - (item 1 of myBounds)--高さ set gItm to {} as list--変数gItmをリストとして初期化しておく。 --左上 set gItm to gItm & my drowLine(X - 13, X - 3, Y, Y, myParent) --オリジナル関数dorwLineを呼び出し、 --結果(ラインオブジェクトが返ってくる)を変数gItemに入れる set gItm to gItm & my drowLine(X - 13, X, Y - 3, Y - 3, myParent) set gItm to gItm & my drowLine(X - 3, X - 3, Y - 13, Y, myParent) set gItm to gItm & my drowLine(X, X, Y - 13, Y - 3, myParent) --上センター set gItm to gItm & my drowLine(X + W / 2, X + W / 2, Y - 13, Y - 3, myParent) set gItm to gItm & my drowLine(X + W / 2 - 5, X + W / 2 + 5, Y - 7, Y - 7, myParent) set gItm to gItm & my drowEllipse(X + W / 2 - 2, Y - 7 - 2, 4, 4, myParent) --右上 set gItm to gItm & my drowLine(X + W + 3, X + W + 13, Y, Y, myParent) set gItm to gItm & my drowLine(X + W, X + W + 13, Y - 3, Y - 3, myParent) set gItm to gItm & my drowLine(X + W + 3, X + W + 3, Y - 13, Y, myParent) set gItm to gItm & my drowLine(X + W, X + W, Y - 13, Y - 3, myParent) --左センター set gItm to gItm & my drowLine(X - 13, X - 3, Y + H / 2, Y + H / 2, myParent) set gItm to gItm & my drowLine(X - 7, X - 7, Y + H / 2 - 5, Y + H / 2 + 5, myParent) set gItm to gItm & my drowEllipse(X - 7 - 2, Y + H / 2 - 2, 4, 4, myParent) --右センター set gItm to gItm & my drowLine(X + W + 3, X + W + 13, Y + H / 2, Y + H / 2, myParent) set gItm to gItm & my drowLine(X + W + 7, X + W + 7, Y + H / 2 - 5, Y + H / 2 + 5, myParent) set gItm to gItm & my drowEllipse(X + W + 7 - 2, Y + H / 2 - 2, 4, 4, myParent) --左下 set gItm to gItm & my drowLine(X - 13, X - 3, Y + H, Y + H, myParent) set gItm to gItm & my drowLine(X - 13, X, Y + H + 3, Y + H + 3, myParent) set gItm to gItm & my drowLine(X - 3, X - 3, Y + H + 13, Y + H, myParent) set gItm to gItm & my drowLine(X, X, Y + H + 13, Y + H + 3, myParent) --下センター set gItm to gItm & my drowLine(X + W / 2, X + W / 2, Y + H + 13, Y + H + 3, myParent) set gItm to gItm & my drowLine(X + W / 2 - 5, X + W / 2 + 5, Y + H + 7, Y + H + 7, myParent) set gItm to gItm & my drowEllipse(X + W / 2 - 2, Y + H + 7 - 2, 4, 4, myParent) --右上 set gItm to gItm & my drowLine(X + W + 3, X + W + 13, Y + H, Y + H, myParent) set gItm to gItm & my drowLine(X + W, X + W + 13, Y + H + 3, Y + H + 3, myParent) set gItm to gItm & my drowLine(X + W + 3, X + W + 3, Y + H + 13, Y + H, myParent) set gItm to gItm & my drowLine(X + W, X + W, Y + H + 13, Y + H + 3, myParent) make group with properties {group items:gItm} --変数gItemをグループ化する。 end if end tell end tell --オリジナル関数dorwLine on drowLine(X1, X2, Y1, Y2, myParent) set buf to {Y1, X1, Y2, X2} tell application "Adobe InDesign CS2_J" tell myParent--変数myParentにはおそらくページが入っている。 make graphic line with properties {geometric bounds:buf, ¬ fill color:"None", stroke color:myCol, stroke weight:lineW * mypt, ¬ item layer:"TOMBO"} --"TOMBO"レイヤーに線を引く end tell end tell end drowLine on drowEllipse(X1, Y1, W1, H1, myParent) set buf to {Y1, X1, Y1 + H1, X1 + W1} tell application "Adobe InDesign CS2_J" tell myParent make ovals with properties {geometric bounds:buf, ¬ fill color:"None", stroke color:myCol, stroke weight:lineW * mypt, ¬ item layer:"TOMBO"} --マルを作成する end tell end tell end drowEllipse
コメントする