●メニューへ ●単福へ ●自動車の維持費をシミュレーション ●InDesign JavaScript ノート

text frame/fontの指定


tell application "Illustrator CS"
    tell document 1
        tell text frame 1
            set Fobj to text font "Osaka" of application "Illustrator CS"
            set text font of characters 1 thru 3 to Fobj
        end tell
    end tell
end tell


TOPへ


サンプル/トンボの作成


global lineW, C, M, Y, K, pt
set lineW to 0.05
--色を入力単位%
set C to 100
set M to 100
set Y to 100
set K to 100
set pt to 2.83466796875

tell application "Adobe Illustrator"
	tell document 1
		set selectedItems to selection
		if selectedItems is {} then
			display dialog "四角をを選択ツールで選択してください。"
			return
		end if
		repeat with selItem in selectedItems
			set myB to geometric bounds of selItem
			my makeTombo(myB)
		end repeat
	end tell
end tell

on makeTombo(myB)
	set X1 to (item 1 of myB) / pt
	set Y1 to (item 2 of myB) / pt
	set X2 to (item 3 of myB) / pt
	set Y2 to (item 4 of myB) / pt
	set myGroup to my makeGroup()
	my makeLine(X1 - 13, Y1, X1 - 3, Y1, myGroup) --横罫左上
	my makeLine(X1 - 13, Y1 + 3, X1, Y1 + 3, myGroup) --横罫左上
	my makeLine(X1, Y1 + 13, X1, Y1 + 3, myGroup) --縦罫左上
	my makeLine(X1 - 3, Y1 + 13, X1 - 3, Y1, myGroup) --縦罫左上
	my makeLine(X1 - 13, Y2, X1 - 3, Y2, myGroup) --横罫左下
	my makeLine(X1 - 13, Y2 - 3, X1, Y2 - 3, myGroup) --横罫左下
	my makeLine(X1, Y2 - 13, X1, Y2 - 3, myGroup) --縦罫左下
	my makeLine(X1 - 3, Y2 - 13, X1 - 3, Y2, myGroup) --縦罫左下
	my makeLine(X2 + 13, Y1, X2 + 3, Y1, myGroup) --横罫右上
	my makeLine(X2 + 13, Y1 + 3, X2, Y1 + 3, myGroup) --横罫右上
	my makeLine(X2, Y1 + 13, X2, Y1 + 3, myGroup) --縦罫右上
	my makeLine(X2 + 3, Y1 + 13, X2 + 3, Y1, myGroup) --縦罫右上
	my makeLine(X2 + 13, Y2, X2 + 3, Y2, myGroup) --横罫右下
	my makeLine(X2 + 13, Y2 - 3, X2, Y2 - 3, myGroup) --横罫右下
	my makeLine(X2, Y2 - 13, X2, Y2 - 3, myGroup) --縦罫右下
	my makeLine(X2 + 3, Y2 - 13, X2 + 3, Y2, myGroup) --縦罫右下
	my makeLine(X1 - 13, Y1 + (Y2 - Y1) / 2, X1 - 3, Y1 + (Y2 - Y1) / 2, myGroup) --横罫左中
	my makeLine(X1 - 8, Y1 + (Y2 - Y1) / 2 - 5, X1 - 8, Y1 + (Y2 - Y1) / 2 + 5, myGroup) --縦罫左中
	my makeEllipse(X1 - 8 - 1.5, (Y1 + (Y2 - Y1) / 2) + 1.5, 3, 3, myGroup) --○丸左中
	my makeLine(X2 + 13, Y1 + (Y2 - Y1) / 2, X2 + 3, Y1 + (Y2 - Y1) / 2, myGroup) --横罫左中
	my makeLine(X2 + 8, Y1 + (Y2 - Y1) / 2 - 5, X2 + 8, Y1 + (Y2 - Y1) / 2 + 5, myGroup) --縦罫左中
	my makeEllipse(X2 + 8 - 1.5, (Y1 + (Y2 - Y1) / 2) + 1.5, 3, 3, myGroup) --○丸右中
	my makeLine(X1 + (X2 - X1) / 2, Y1 + 13, X1 + (X2 - X1) / 2, Y1 + 3, myGroup) --縦罫中上
	my makeLine(X1 + (X2 - X1) / 2 - 5, Y1 + 8, X1 + (X2 - X1) / 2 + 5, Y1 + 8, myGroup) --横罫中上
	my makeEllipse(X1 + (X2 - X1) / 2 - 1.5, Y1 + 8 + 1.5, 3, 3, myGroup) --○丸中上
	my makeLine(X1 + (X2 - X1) / 2, Y2 - 13, X1 + (X2 - X1) / 2, Y2 - 3, myGroup) --縦罫中下
	my makeLine(X1 + (X2 - X1) / 2 - 5, Y2 - 8, X1 + (X2 - X1) / 2 + 5, Y2 - 8, myGroup) --横罫中下
	my makeEllipse(X1 + (X2 - X1) / 2 - 1.5, Y2 - 8 + 1.5, 3, 3, myGroup) --○丸中下
end makeTombo

on makeLine(X1, Y1, X2, Y2, myGroup)
	set X1 to X1 * pt
	set Y1 to Y1 * pt
	set X2 to X2 * pt
	set Y2 to Y2 * pt
	set W to lineW * pt
	tell application "Adobe Illustrator"
		tell document 1
			make new path item at end of myGroup with properties {stroke color:{cyan:C, magenta:M, yellow:Y, black:K}, stroke width:W, entire path:{{class:path point info, anchor:{X1, Y1}}, {class:path point info, anchor:{X2, Y2}}}}
		end tell
	end tell
end makeLine

on makeEllipse(X1, Y1, W, H, myGroup)
	tell application "Adobe Illustrator"
		tell document 1
			set X1 to X1 * pt
			set Y1 to Y1 * pt
			set myW to W * pt
			set myH to H * pt
			set W to lineW * pt
			make new ellipse at end of myGroup with properties {filled:false, stroked:true, stroke color:{cyan:C, magenta:M, yellow:Y, black:K}, width:myW, height:myH, position:{X1, Y1}, stroke width:W}
		end tell
	end tell
end makeEllipse

on makeGroup()
	tell application "Adobe Illustrator"
		tell document 1
			if exists group item "TOMBO" then
				set myGroup to group item "TOMBO"
			else
				set myGroup to make group item at beginning with properties {name:"TOMBO"}
			end if
		end tell
	end tell
	return myGroup
end makeGroup


TOPへ