毎日モザイク

White Room Layout Works

2012-06-22T13:34:54+09:00 [Fri]

indesign 角丸修正

サイズ変更時にめんどくさいので、変更してからもう一度やればいいように変更。

■の外側に追加する方は大きさが変わるんで放置。位置決めが変わらない内側で何とかするタイプだけ。

tell application "Adobe InDesign CS5"
	tell document 1
		try
			set ss to object reference of selection
		on error
			display dialog "選択されていません" buttons {"キャンセル"} default button 1
		end try
		set {button returned:btres} to display dialog "上下or左右" buttons {"上下", "左右", "キャンセル"} default button 3
		repeat with s in ss
			convert shape s given convert to rectangle
			set r to rotation angle of s
			tell application "Adobe InDesign CS5"
				set myRotateMatrix_org to make transformation matrix with properties {counterclockwise rotation angle:r}
				set myRotateMatrix_flat to make transformation matrix with properties {counterclockwise rotation angle:-r}
			end tell
			transform s in pasteboard coordinates from center anchor with matrix myRotateMatrix_flat
			set {y, x, yy, xx} to geometric bounds of s
			set {pr1, pr2, ps} to {{y, x, yy, x + yy - y}, {y, xx - (yy - y), yy, xx}, {y, x + ((yy - y) / 2), yy, xx - ((yy - y) / 2)}}
			if btres = "上下" then set {pr1, pr2, ps} to {{y, x, y + xx - x, xx}, {yy - (xx - x), x, yy, xx}, {y + ((xx - x) / 2), x, yy - ((xx - x) / 2), xx}}
			set r1 to duplicate s
			convert shape r1 given convert to oval
			set geometric bounds of r1 to pr1
			set r2 to duplicate s
			convert shape r2 given convert to oval
			set geometric bounds of r2 to pr2
			set geometric bounds of s to ps
			set ns to add path s with {r1, r2}
			transform ns in pasteboard coordinates from center anchor with matrix myRotateMatrix_org
		end repeat
	end tell
end tell