02)プロパティを調べる・セットする get properties

| コメント(0) | トラックバック(0)

AppleScriptでアプリケーションをコントロールする最も簡単な方法は適当にオブジェクト(テキストなど)をInDesignやIllustratorで作ってプロパティを調べる方法です。調べたらそれを変更できるかやってみます。
Illustratorに"あいうえお"というテキストを作りプロパティを見ましょう。

tell application "Adobe Illustrator"--Illustratorの
	tell document 1--最前面のドキュメントの
		tell page item 1--最前面のアイテムの
			get properties--プロパティを調べる
		end tell
	end tell
end tell

このget propertiesは「QuarkXPressを操ろう」をNiftyのFPRINTフォーラムで連載されてい鎌田さんゆずりの方法でこれを初めて知って以来いろんなオブジェクトにget propertiesしてきました。いまAppleScriptが使えるようになったのもこのget propertiesのおかげです。

さていろいろな値がかえってきました。抜粋します。

contents:"あいうえお", 
text orientation:horizontal, 
position:{86.22216796875, 641.115234375},
width:60.0,
height:15.0361328125,
name:"",
class:text frame,
index:1

まず注目はclassです。このテキストのクラス名はtext frameだということがわかります。indexは1なのでpage item 1ではなくてtext frame 1で指定する方が良いでしょう。contents:"あいうえお"とあります。これを変えてみましょう。変更するにはAppleScriptで変数に値を入れる方法と同じです。
set 変数 to ○○
でしたね。では

tell application "Adobe Illustrator"--Illustratorの
	tell document 1--最前面のドキュメントの
		tell text frame 1--最前面のtext frameの
			set contents to "かきくけこ"--contentsを"かきくけこ"にする。
		end tell
	end tell
end tell

これを動かしてください。文字内容が変わりましたね。

tell application "Adobe Illustrator"
	tell document 1
		tell text frame 1
			set position to {100, 100}
		end tell
	end tell
end tell

を動かすと文字の場所が変わります。場所とcontentsを一度にセットすることも出来ます。

tell application "Adobe Illustrator"
	tell document 1
		tell text frame 1
			set properties to {position:{100, 100}, contents:"かきくけこ"}
		end tell
	end tell
end tell

もちろんget propertiesだけではAppleScriptでInDesignをコントロールするだけの情報を調べるのは困難です。text frame 1でget propertiesしてもフォントやカラーのプロパティはありませんでした。実際フォントやカラーはtext frameのプロパティではなくtext frameの要素であるparagraphやcharacterのプロパティです。しかし、それを調べるのはget propertiesだけでは無理です。このようにもっといろいろ調べたい場合は後述する用語辞書やリファレンスを見ます。

トラックバック(0)

トラックバックURL: http://www.adg7.com/mt/mt-tb.cgi/42

Comments are nofollow setting

コメントする

エントリー一覧

OpenID対応しています OpenIDについて
Powered by Movable Type 7.902.0
漢字イラストロジック-脳トレ京
FREE ONLINE SUDOKU