
33
4
Scripting with AppleScript
This chapter uses script examples and explanations to help you to become familiar with Illustrator
scripting using AppleScript.
For more information
Several extended sample scripts are in the
:Scripting:Sample
Scripts
folder in your Illustrator CS4
installation directory.
For information about individual classes, objects, properties, commands, and parameters, as well as script
samples that demonstrate how to use many of these items, see
Adobe Illustrator CS4 Scripting Reference:
AppleScript
, in the
:Scripting:Documentation
folder in your Illustrator CS4 installation directory. You
also can view the Illustrator CS4 dictionary from the Script Editor application;see
“Viewing the AppleScript
object model” on page 8
.
If you do not understand the concepts and terms used in this chapter, read
Adobe Introduction to Scripting
.
Your first Illustrator script
The traditional first project in any programming language is displaying the message “Hello World!” In this
example, you create a new Illustrator document, then add a text frame containing this message. Follow
these steps:
1.
Open Script Editor.
In a default Mac OS installation, Script Editor is in
Applications:AppleScript:Script
Editor
. If you
cannot find the Script Editor application, you must reinstall it from your Mac OS system CD.
2.
Enter the following script.
--Send the following commands to Illustrator
tell application "Adobe Illustrator"
--Create a new document
set docRef to make new document
--Create a new text frame with the string "Hello World"
set textRef to make new text frame in docRef
with properties {contents: "Hello World!", position:{200, 200}}
end tell
3.
In the Script Editor toolbar, click Run.
T
IP
:
To add the script to the Illustrator Scripts menu (File > Scripts), save the script in the Scripts folder. The
script will appear on the menu the next time you start Illustrator. For details, see
“Installing scripts in the
Scripts menu” on page 10
.