Adobe Illustrator CS User manual

Category
Desktop publishing software
Type
User manual

This manual is also suitable for

Adobe Developer Support
345 Park Avenue
San Jose, CA 95110-2704
408-536-9000
FaxYI: 206-628-5737
Europe:
PO Box 12356
Edinburgh EH11 4GJ
United Kingdom
+44.131.458.6800
Fax: +44.131.458 6801
http://partners.adobe.com
a
Adobe Illustrator CS
Scripting Guide
August 12, 2003
ii
Adobe Illustrator CS Scripting Guide
Copyright 2000, 2002–2003 Adobe Systems Incorporated.
All Rights Reserved.
The information in this document is furnished for informational use only, is subject to change without notice, and
should not be construed as a commitment by Adobe Systems Incorporated. Adobe Systems Incorporated assumes
no responsibility or liability for any errors or inaccuracies that may appear in this document. The software described
in this document is furnished under license and may only be used or copied in accordance with the terms of such
license.
Adobe, the Adobe logo, Adobe Acrobat, Adobe Photoshop, Adobe Illustrator, Adobe InDesign, and PostScript are
trademarks of Adobe Systems Incorporated that may be registered in certain jurisdictions. Macintosh and Apple are
registered trademarks, and Mac OS and AppleScript are trademarks of Apple Computer, Inc. Microsoft, Visual Basic,
Windows, Windows 95, Windows 98, and Windows NT are registered trademarks of Microsoft Corporation. All other
products or name brands are trademarks of their respective holders.
iii
Contents
Chapter 1: Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
About this manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13
What is scripting? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14
Why use scripting? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14
What about actions? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15
System requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15
Mac OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16
Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16
Chapter 2: Scripting Basics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Object model concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17
Object classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18
Object inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18
Object elements or collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19
Object references . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19
Scripting concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19
About long script lines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20
Values Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21
Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22
Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23
Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
Commands and methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
Conditional statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
Control structures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
Handlers and subroutines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27
Testing and troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29
About error handling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31
iv
Chapter 3: Scripting Illustrator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Illustrator’s object model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33
Looking at Illustrator’s objects and commands . . . . . . . . . . . . . . . . . . . . . . . . . . .34
AppleScript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34
Visual Basic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36
The application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36
Your first Illustrator script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37
Creating an AppleScript script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37
Creating a Visual Basic script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37
VBScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39
Adding features to “Hello World” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40
Measurement units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42
Unit conversion to points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43
Em Space Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43
Coordinates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44
Fixed points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44
Zero point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44
Fixed rectangle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45
Page item positioning and dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45
Object references . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46
Object references in AppleScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46
Object references in Visual Basic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47
Object containment: document vs. layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48
Working with selections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49
Working with paths. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52
Working with color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52
Working with symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53
Working with symbol items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53
Working with text art. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53
Content of a Text Range. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55
Character Style, Character Attributes, Local Character Attributes. . . . . . . . . . . . .55
Printing Illustrator Documents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55
Transformation matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .56
Using a matrix in an AppleScript script . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57
Using a matrix in a Visual Basic script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57
Working with variables and datasets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58
Datasets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58
Launching and quitting Illustrator from a script . . . . . . . . . . . . . . . . . . . . . . . . . . .58
Launching and quitting from AppleScript . . . . . . . . . . . . . . . . . . . . . . . . . . .58
Launching and quitting from Visual Basic . . . . . . . . . . . . . . . . . . . . . . . . . . .59
Some objects that cannot be created by a script . . . . . . . . . . . . . . . . . . . . . . . . . .59
Adobe Illustrator CS Scripting Guide v
User Interaction Levels. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .59
AppleScript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60
Visual Basic and JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60
The Scripts menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60
Notes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61
Supported scripting languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61
Script files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61
Installing scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61
Executing other scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62
Chapter 4: AppleScript Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
About the script examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63
application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .64
brush, brushes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67
character . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69
character style, character styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .76
CMYK color info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82
color info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83
color management options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84
color separation options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84
compound path item, compound path items . . . . . . . . . . . . . . . . . . . . . . . . . . . .85
coordinate options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .87
dataset, datasets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .88
document, documents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .91
ellipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98
EPS save options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Flash export options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
flattening options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
font, fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
font options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
GIF export options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
gradient, gradients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
gradient color info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
gradient stop, gradient stops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
gradient stop info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
graph item, graph items. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
graphic style, graphic styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
gray color info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
group item, group items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
Illustrator preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
vi
Illustrator save options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
ink. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
ink properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
insertion point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
job options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
JPEG export options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
layer, layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
mesh item, mesh items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
no color info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Open Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
page item, page items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
page marks options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
paper. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
paper options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
paper properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
paragraph, paragraphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
paragraph style, paragraph styles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
path item, path items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
path point, path points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
path point info. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
pattern, patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
pattern color info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
PDF options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
PDF save options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Photoshop options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Photoshop export options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
placed item, placed items. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
plugin item, plugin items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
PNG24 export options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
PNG8 export options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
polygon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
postscript options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
PPD file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
PPD properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
print options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
printer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
printer properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
raster item, raster items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
rectangle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
RGB color info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Adobe Illustrator CS Scripting Guide vii
rounded rectangle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
screen properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
screen spot function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
separation screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
spot, spots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
spot color info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
star . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
story, stories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
SVG export options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
swatch, swatches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
symbol, symbols. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
symbol item, symbol items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
tab stop info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
tag, tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
text, texts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
text frame, text frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
variable, variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
view, views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
word . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
Command reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
apply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
apply character style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
apply paragraph style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
change case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
close . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
colorize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
concatenate matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
concatenate rotation matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
concatenate scale matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
concatenate translation matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
convert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
convert to paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
copy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
count. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
cut . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
delete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
deselect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
do javascript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
do script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
duplicate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
equal matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
viii
exists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
export PDF preset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
export print presets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
export variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
get identity matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
get rotation matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
get scale matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
get translation matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
import character styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
import paragraph styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
import PDF preset. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
import print preset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
import variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
invert matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
make . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
move . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
open . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
paste . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
print . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
quit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
redraw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
rotate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
save. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
scale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
select . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
show presets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
singular matrix. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
translate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
translate placeholder text. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
update . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
Chapter 5: Visual Basic Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
About the script examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
Referencing and creating objects in Visual Basic . . . . . . . . . . . . . . . . . . . . . . . . . 288
Syntax differences between Sub and Function methods . . . . . . . . . . . . . . . . . 289
Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
Adobe Illustrator CS Scripting Guide ix
Brush . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
Brushes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
CharacterAttributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
Characters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
CharacterStyle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
CharacterStyles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
CMYKColor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
CompoundPathItem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
CompoundPathItems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
DataSet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310
DataSets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
Document. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
EPSSaveOptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
ExportOptionsFlash. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
ExportOptionsGIF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
ExportOptionsJPEG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
ExportOptionsPhotoshop. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326
ExportOptionsPNG24 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
ExportOptionsPNG8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
ExportOptionsSVG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
Gradient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
Gradients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
GradientColor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
GradientStop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
GradientStops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
GraphicStyle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
GraphicStyles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
GraphItem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
GraphItems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344
GrayColor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
GroupItem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
GroupItems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
IllustratorSaveOptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
Ink. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
InkInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
InsertionPoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
InsertionPoints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
Layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
LegacyTextItem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
LegacyTextItems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364
x
Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364
Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366
MeshItem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
MeshItems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370
NoColor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
OpenOptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373
PageItems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
Paper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
PaperInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
ParagraphAttributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
Paragraphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
ParagraphStyle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
ParagraphStyles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
PathItem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
PathItems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389
PathPoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
PathPoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394
PatternColor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
PDFFileOptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
PDFSaveOptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
PhotoshopFileOptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
PlacedItem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402
PlacedItems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406
PluginItem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406
PluginItems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
PPDFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
PPDFileInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
PrintColorManagementOptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
PrintColorSeparationOptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
PrintCoordinateOptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
Printer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
PrinterInfo. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
PrintFlattenerOptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419
PrintFontOptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421
PrintJobOptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
PrintOptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424
PrintPageMarksOptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
PrintPaperOptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
PrintPostScriptOptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
Adobe Illustrator CS Scripting Guide xi
RasterItem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
RasterItems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
RGBColor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435
ScreenInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
ScreenSpotFunction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
Spot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
Spots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
SpotColor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
Story . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
Stories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442
Swatch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443
Swatches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444
Symbol. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
SymbolItem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
SymbolItems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451
TabStopInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452
Tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452
Tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454
TextFont. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
TextFonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456
TextFrame. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457
TextFrames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461
TextRange. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464
TextRanges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466
Variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466
Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
Words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470
Enumerations reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
Chapter 6: Changes Since Earlier Versions. . . . . . . . . . . . . . . . . . . . . . . . 487
Changes InThe Object Model for Illustrator CS. . . . . . . . . . . . . . . . . . . . . . . . . . . 487
Macintosh / AppleScript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487
Windows / COM (Visual Basic, et al). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487
Deprecated. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
xii
Chapter : Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
AppleScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
Visual Basic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
Internet resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492
Adobe Systems, Inc. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492
AppleScript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492
Visual Basic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492
13
1
Introduction
About this manual
This manual provides an introduction to scripting Adobe® Illustrator® CS on Mac OS 10 and
Windows. Since not every Illustrator user will be familiar with programming terms, concepts,
and techniques, so we’ve included Chapter 2, “Scripting Basics, which contains introductory
information that should help get you started with scripting. If youre an experienced
AppleScript scripter or Visual Basic programmer, you will probably want to skip Chapter 2 and
proceed with Chapter 3 to get the specifics on scripting Illustrator.
This document contains the following chapters:
1. Introduction — An introduction to scripting.
2. Scripting BasicsThe basics of each platforms scripting language: AppleScript in
Mac OS and Visual Basic in Windows. If you are new to scripting, be sure to read this
chapter. Beginners are heartily encouraged to consult the Bibliography for books on
AppleScript and Visual Basic.
3. Scripting Illustrator — A brief introduction to the specifics of scripting Illustrator.
Concepts and approaches specific to the application are covered here, such as
measurement units, matrices, and color models.
4. AppleScript Reference — Here you’ll find details and examples for every object and
command in Illustrators AppleScript dictionary.
5. Visual Basic Reference — Details and examples are provided for every class in
Illustrators Visual Basic type library.
6. Bibliography — A bibliography of helpful resources for learning more about
scripting.
7. Changes Since Earlier Versions — Describes changes made since earlier versions of
Illustrator Scripting
Introduction14
12 Aug 03
What is scripting?
A script is a series of commands that tells Illustrator to perform a series of actions. These actions
can be simple, and affect only a single, selected object in the current document; or complex,
and affect all of the objects in all of your Illustrator documents. The actions might involve only
Illustrator, or they might involve other applications, such as word processors, spreadsheets, and
database management programs. Many of the tasks you can perform with Illustrators tools,
menus, palettes, and dialog boxes can be performed by a script (a notable exception is third-
party plug-ins, which cannot be scripted at this time).
We naturally think of scripting as a way to automate repetitive tasks, but it can also be a
creative tool. You can use scripts for creative tasks that would be too difficult or time
consuming to do manually. For example, you could write a script to systematically create a
series of objects, modifying the new objects’ position, stroke, and fill properties along the way.
You could also write a script that accessed Illustrators built-in transformation matrix functions
to stretch, scale and distort a series of objects. Without scripting, you’ll likely miss out on the
creative potential of such labor-intensive techniques.
Scripting isn’t just for computer programmers—it’s for everybody. You don’t need a degree in
computer science or mathematics to write scripts that can automate a wide variety of common
tasks. If you can read this text, you can write scripts.
Why use scripting?
Graphic design is a field characterized by creativity, but aspects of the actual work of
illustration and page layout are anything but creative. When you think about the work that you
do, chances are good you’ll find that you spend most of your time doing the same or similar
production tasks, over and over again. In fact, you’ll probably notice that the time you spend
placing and replacing images, correcting errors in text, and preparing files for printing at an
imagesetting service provider often reduce the time you have available for doing creative
work.
Wouldn’t it be great if you had an assistant—one that wouldn’t mind doing some or all of the
boring, repetitive tasks for you? With that kind of help, youd have more time to concentrate on
the creative aspects of your work.
With a small investment of time, Illustrator scripting can be the assistant you need. You can
start with short, simple scripts that save you a few seconds every day, and move on to scripts
that work all night while you’re sleeping.
Adobe Illustrator CS Scripting Guide 15
12 Aug 03
Think about your work—is there a repetitive task that’s driving you crazy? If so, you’ve
identified a candidate for a script. What are the steps involved in performing the task? What are
the conditions in which you need to do the task? Once you understand the process you go
through to perform the task, you’ll be ready to turn it into a script.
What about actions?
Illustrator actions are different from scripts. An Illustrator action is a series of tasks you have
recorded while using the application—menu choices, tool choices, object selection, and other
commands. When you “play an action, Illustrator performs all of the recorded commands.
You record, play, edit and delete actions using Illustrators built-in Actions palette. The
“Automating Tasks” chapter in the Adobe Illustrator User Guide covers actions in detail.
With the introduction of scripting for Illustrator, it is important to avoid any confusion about
the difference between actions and scripting. Actions and scripts are both ways of automating
repetitive tasks, but they work very differently. The following points summarize the key
differences.
•Actions use a programs user interface to do their work. As an action runs, menu choices
are executed, objects are selected, and recorded paths are created. Scripts do not use a
programs user interface to perform tasks, and can execute faster than actions.
•Actions have very limited facilities for getting and responding to information. You cannot
add conditional logic to an action. Therefore, actions cannot make decisions based on the
current situation. Scripts are capable of getting information and making decisions and
calculations based on the information they receive from Illustrator.
•A script can execute an action, but actions cannot execute scripts.
System requirements
The language you use to write scripts depends on the operating system of the platform youre
using: AppleScript for Mac OS; Visual Basic for Windows. While the two scripting systems differ,
the ways that they work with Illustrator are very similar. Each example script shown in this
manual will be shown in both systems. Make sure the scripting plug-in is installed on your
system before attempting to script Illustrator.
Introduction16
12 Aug 03
Mac OS
To write scripts on Mac OS, you must have Mac OS X 10.2. You will also need AppleScript and a
script editor installed. AppleScript and the Script Editor application from Apple come installed
on all supported versions of Mac OS.
As your scripts become more complex, you may find the need for debugging and productivity
features not found in Script Editor. For information on those topics, see the AppleScript page at
http://www.apple.com/applescript/.
We use the Script Editor from Apple in this manual.
Windows
To use Illustrator scripting in Windows, you must have Windows 98, Windows NT 4.0,
Windows 2000, or WIndows XP. You will also need the Microsoft Visual Basic development
environment or one of the applications that contain a Visual Basic editor. Many applications
that support the Visual Basic for Applications (VBA) language contain a built-in editor.
Applications that contain a built-in editor include: Microsoft Word, Microsoft Excel, and Visio.
You can use any Visual Basic editor to create your scripts.
As your scripts become more complex or require a user interface, you will find the need for a
complete development environment than one of the built-in editors. The Microsoft Visual Basic
development environment comes in a variety of package, all of which provide everything you
need to script Illustrator.
In this manual, we use the Microsoft Visual Basic development environments editor.
17
2
Scripting Basics
If you use Illustrator, then you work with documents and their contents. You create documents,
layers, colors, and design elements. If you do all of this, you’ve probably gotten used to thinking
of an Illustrator document as a series of objects.
Automating Illustrator with scripting uses the same object-oriented way of thinking. The heart
of a scriptable application is the object model. In Illustrator, the object model contains
documents, layers, colors, and page items—objects that can appear in an Illustrator document.
Each type of object has its own special properties, and every object in an Illustrator document
has its own identity.
In this chapter, we’ll cover the basic concepts of scripting for both AppleScript on Mac OS and
Visual Basic on Windows. This brief introduction to the basic concepts and syntax of each
scripting language is by no means complete or exhaustive. The bibliography contains
references to more complete language guides for both scripting languages.
For detailed information on using your particular scripting system with Illustrator, see the
appropriate reference chapter later in this manual. Experienced scripters may want to skip to
those chapters now.
Object model concepts
The terminology of object oriented programming can be hard to understand, at first. “Objects”
belong to classes” and have properties” you manipulate using commands” (AppleScript) or
methods” (Visual Basic). What do these words mean in this context?
Heres a way to think about objects and their properties. Imagine that you live in a house that
responds to your commands (you can think of this house as technologically advanced, or
magical, or both). The house is an object, and its properties might include the number of
rooms, the color of the exterior paint, or the date of its construction.
Object model concepts18
12 Aug 03
Your house can also contain other objects. Just like your house can contain other objects, the
objects within the house can also contain a number of smaller objects. Each room, for example,
is an object in the house, while each window, door, or appliance is an object inside of the room.
Each object can respond to various commands according to its capabilities. Windows and
doors, for example, can open or close—but the floor and ceiling cannot. Using scripting, you
can talk to each object directly, or you can talk to them as part of the house. You have to be very
specific, though—you can’t tell your house to open a window without telling it which window
you want to open. So windows, just like all other objects, need names or at least a numbering
system so you can refer to them specifically. For example, you might say Tell the house to open
the north window of the living room.”
Objects also have properties that describe specific details about them, like color and size.
Imagine that the properties of objects in your house can be changed. You might say, “Door,
paint yourself blue. Because your door can respond to the command paint, you’ll soon have a
door of a different color.
Now let’s apply this object model idea to Illustrator. The Illustrator application is the house, its
documents are the rooms, and the objects in your documents are the windows and doors. You
can tell Illustrator documents to add and remove objects. You can ask objects to get or change
their properties.
Object classes
Objects with the same properties and behaviors are grouped into classes.” In the house
example, windows and doors belong to their own classes, since they have unique properties,
like number of panes for windows or the door style for doors. In Illustrator, every type of
graphic object—paths, text, meshes, etc.—belongs to its own class, each with its own set of
properties and behaviors. Properties such as
visible
bounds
,
width
, and
height
, for
example, are common to all
page
items
.
Object inheritance
Object classes may also inherit, or share, the properties of a parent, or superclass. When an
class inherits properties, we call that class a child, or subclass of the class from which it inherits
properties. So in our house example, windows and doors are subclasses of an openings class,
since they are both openings in a house. In Illustrator,
path
items
, for example, inherit
geometric properties like
width
and
height
from the
page
item
class.
Classes will often have properties that aren’t shared with their superclass. In our house, both a
window and door inherit an opened property from the opening class, but a window has
Adobe Illustrator CS Scripting Guide
19
12 Aug 03
number of panes property which the opening class doesn’t. In Illustrator,
path
items
, for
example, have the property
stroke
color
which isnt inherited from the
page
item
class.
Object elements or collections
Object elements (AppleScript) or collections (Visual Basic) are objects contained within other
objects. For example, rooms are elements (or collections) of our house, contained within the
house object. In Illustrator, documents are elements of the application object, and page items
are elements of a document object.
Object references
The objects in your documents are arranged in a hierarchy like the house object—page items
are in layers, which are inside a document, which is inside Illustrator. When you send a
command to an Illustrator object, you need to make sure you send the message to the right
object. To do this, you identify objects by their position in the hierarchy. You might, for
example, write the following statement.
AppleScript
page item 1 of layer 1 of document 1
Visual Basic
Documents(1).Layers(1).PageItems(1)
When you identify an object in this fashion, youre creating an
object reference
. AppleScript and
Visual Basic use different ways of creating object references, but the idea is the same—to give
the script a way of finding the object you want to work with.
Scripting concepts
Comments
Comments are a way to add descriptive text to a script. Comments come in handy when you
want to document the operation of a script (for yourself or for someone else). The use of
comments is the most important technique for good scripting. Comments are where you
should leave important notes about the specific operation of a script that might provide
Scripting concepts20
12 Aug 03
valuable help when the script is modified at a later date. The time you save later trying to figure
out what the script does may be your own. Comments are ignored by the scripting system as
the script executes and cause no run-time speed penalty.
AppleScript
To enter a single-line comment in an AppleScript, type “--” to the left of your description. For
multiple line comments, start your comment with the characters “(*” and end it with “*)”.
-- this is a single-line comment
(* this is a
multiple line comment *)
Visual Basic
In Visual Basic, enter “'” (a single straight quote) to the left of the comment.
' This is a comment
About long script lines
In some cases, individual script lines are too long to print on a single line in this guide.
AppleScript
AppleScript uses the special character (¬) to show that the line continues to the next line. This
continuation character denotes a soft return in the script. You can enter this character in the
script editor by pressing Option-Return at the end of the line you wish to continue.
Visual Basic
Visual Basic uses a special character – the underline character (“_”) to show that the line
continues to the next line. This continuation character denotes a soft return in the script. You
can enter this character in the editor by pressing Shift--(dash) at the end of the line you wish to
continue.
  • Page 1 1
  • Page 2 2
  • Page 3 3
  • Page 4 4
  • Page 5 5
  • Page 6 6
  • Page 7 7
  • Page 8 8
  • Page 9 9
  • Page 10 10
  • Page 11 11
  • Page 12 12
  • Page 13 13
  • Page 14 14
  • Page 15 15
  • Page 16 16
  • Page 17 17
  • Page 18 18
  • Page 19 19
  • Page 20 20
  • Page 21 21
  • Page 22 22
  • Page 23 23
  • Page 24 24
  • Page 25 25
  • Page 26 26
  • Page 27 27
  • Page 28 28
  • Page 29 29
  • Page 30 30
  • Page 31 31
  • Page 32 32
  • Page 33 33
  • Page 34 34
  • Page 35 35
  • Page 36 36
  • Page 37 37
  • Page 38 38
  • Page 39 39
  • Page 40 40
  • Page 41 41
  • Page 42 42
  • Page 43 43
  • Page 44 44
  • Page 45 45
  • Page 46 46
  • Page 47 47
  • Page 48 48
  • Page 49 49
  • Page 50 50
  • Page 51 51
  • Page 52 52
  • Page 53 53
  • Page 54 54
  • Page 55 55
  • Page 56 56
  • Page 57 57
  • Page 58 58
  • Page 59 59
  • Page 60 60
  • Page 61 61
  • Page 62 62
  • Page 63 63
  • Page 64 64
  • Page 65 65
  • Page 66 66
  • Page 67 67
  • Page 68 68
  • Page 69 69
  • Page 70 70
  • Page 71 71
  • Page 72 72
  • Page 73 73
  • Page 74 74
  • Page 75 75
  • Page 76 76
  • Page 77 77
  • Page 78 78
  • Page 79 79
  • Page 80 80
  • Page 81 81
  • Page 82 82
  • Page 83 83
  • Page 84 84
  • Page 85 85
  • Page 86 86
  • Page 87 87
  • Page 88 88
  • Page 89 89
  • Page 90 90
  • Page 91 91
  • Page 92 92
  • Page 93 93
  • Page 94 94
  • Page 95 95
  • Page 96 96
  • Page 97 97
  • Page 98 98
  • Page 99 99
  • Page 100 100
  • Page 101 101
  • Page 102 102
  • Page 103 103
  • Page 104 104
  • Page 105 105
  • Page 106 106
  • Page 107 107
  • Page 108 108
  • Page 109 109
  • Page 110 110
  • Page 111 111
  • Page 112 112
  • Page 113 113
  • Page 114 114
  • Page 115 115
  • Page 116 116
  • Page 117 117
  • Page 118 118
  • Page 119 119
  • Page 120 120
  • Page 121 121
  • Page 122 122
  • Page 123 123
  • Page 124 124
  • Page 125 125
  • Page 126 126
  • Page 127 127
  • Page 128 128
  • Page 129 129
  • Page 130 130
  • Page 131 131
  • Page 132 132
  • Page 133 133
  • Page 134 134
  • Page 135 135
  • Page 136 136
  • Page 137 137
  • Page 138 138
  • Page 139 139
  • Page 140 140
  • Page 141 141
  • Page 142 142
  • Page 143 143
  • Page 144 144
  • Page 145 145
  • Page 146 146
  • Page 147 147
  • Page 148 148
  • Page 149 149
  • Page 150 150
  • Page 151 151
  • Page 152 152
  • Page 153 153
  • Page 154 154
  • Page 155 155
  • Page 156 156
  • Page 157 157
  • Page 158 158
  • Page 159 159
  • Page 160 160
  • Page 161 161
  • Page 162 162
  • Page 163 163
  • Page 164 164
  • Page 165 165
  • Page 166 166
  • Page 167 167
  • Page 168 168
  • Page 169 169
  • Page 170 170
  • Page 171 171
  • Page 172 172
  • Page 173 173
  • Page 174 174
  • Page 175 175
  • Page 176 176
  • Page 177 177
  • Page 178 178
  • Page 179 179
  • Page 180 180
  • Page 181 181
  • Page 182 182
  • Page 183 183
  • Page 184 184
  • Page 185 185
  • Page 186 186
  • Page 187 187
  • Page 188 188
  • Page 189 189
  • Page 190 190
  • Page 191 191
  • Page 192 192
  • Page 193 193
  • Page 194 194
  • Page 195 195
  • Page 196 196
  • Page 197 197
  • Page 198 198
  • Page 199 199
  • Page 200 200
  • Page 201 201
  • Page 202 202
  • Page 203 203
  • Page 204 204
  • Page 205 205
  • Page 206 206
  • Page 207 207
  • Page 208 208
  • Page 209 209
  • Page 210 210
  • Page 211 211
  • Page 212 212
  • Page 213 213
  • Page 214 214
  • Page 215 215
  • Page 216 216
  • Page 217 217
  • Page 218 218
  • Page 219 219
  • Page 220 220
  • Page 221 221
  • Page 222 222
  • Page 223 223
  • Page 224 224
  • Page 225 225
  • Page 226 226
  • Page 227 227
  • Page 228 228
  • Page 229 229
  • Page 230 230
  • Page 231 231
  • Page 232 232
  • Page 233 233
  • Page 234 234
  • Page 235 235
  • Page 236 236
  • Page 237 237
  • Page 238 238
  • Page 239 239
  • Page 240 240
  • Page 241 241
  • Page 242 242
  • Page 243 243
  • Page 244 244
  • Page 245 245
  • Page 246 246
  • Page 247 247
  • Page 248 248
  • Page 249 249
  • Page 250 250
  • Page 251 251
  • Page 252 252
  • Page 253 253
  • Page 254 254
  • Page 255 255
  • Page 256 256
  • Page 257 257
  • Page 258 258
  • Page 259 259
  • Page 260 260
  • Page 261 261
  • Page 262 262
  • Page 263 263
  • Page 264 264
  • Page 265 265
  • Page 266 266
  • Page 267 267
  • Page 268 268
  • Page 269 269
  • Page 270 270
  • Page 271 271
  • Page 272 272
  • Page 273 273
  • Page 274 274
  • Page 275 275
  • Page 276 276
  • Page 277 277
  • Page 278 278
  • Page 279 279
  • Page 280 280
  • Page 281 281
  • Page 282 282
  • Page 283 283
  • Page 284 284
  • Page 285 285
  • Page 286 286
  • Page 287 287
  • Page 288 288
  • Page 289 289
  • Page 290 290
  • Page 291 291
  • Page 292 292
  • Page 293 293
  • Page 294 294
  • Page 295 295
  • Page 296 296
  • Page 297 297
  • Page 298 298
  • Page 299 299
  • Page 300 300
  • Page 301 301
  • Page 302 302
  • Page 303 303
  • Page 304 304
  • Page 305 305
  • Page 306 306
  • Page 307 307
  • Page 308 308
  • Page 309 309
  • Page 310 310
  • Page 311 311
  • Page 312 312
  • Page 313 313
  • Page 314 314
  • Page 315 315
  • Page 316 316
  • Page 317 317
  • Page 318 318
  • Page 319 319
  • Page 320 320
  • Page 321 321
  • Page 322 322
  • Page 323 323
  • Page 324 324
  • Page 325 325
  • Page 326 326
  • Page 327 327
  • Page 328 328
  • Page 329 329
  • Page 330 330
  • Page 331 331
  • Page 332 332
  • Page 333 333
  • Page 334 334
  • Page 335 335
  • Page 336 336
  • Page 337 337
  • Page 338 338
  • Page 339 339
  • Page 340 340
  • Page 341 341
  • Page 342 342
  • Page 343 343
  • Page 344 344
  • Page 345 345
  • Page 346 346
  • Page 347 347
  • Page 348 348
  • Page 349 349
  • Page 350 350
  • Page 351 351
  • Page 352 352
  • Page 353 353
  • Page 354 354
  • Page 355 355
  • Page 356 356
  • Page 357 357
  • Page 358 358
  • Page 359 359
  • Page 360 360
  • Page 361 361
  • Page 362 362
  • Page 363 363
  • Page 364 364
  • Page 365 365
  • Page 366 366
  • Page 367 367
  • Page 368 368
  • Page 369 369
  • Page 370 370
  • Page 371 371
  • Page 372 372
  • Page 373 373
  • Page 374 374
  • Page 375 375
  • Page 376 376
  • Page 377 377
  • Page 378 378
  • Page 379 379
  • Page 380 380
  • Page 381 381
  • Page 382 382
  • Page 383 383
  • Page 384 384
  • Page 385 385
  • Page 386 386
  • Page 387 387
  • Page 388 388
  • Page 389 389
  • Page 390 390
  • Page 391 391
  • Page 392 392
  • Page 393 393
  • Page 394 394
  • Page 395 395
  • Page 396 396
  • Page 397 397
  • Page 398 398
  • Page 399 399
  • Page 400 400
  • Page 401 401
  • Page 402 402
  • Page 403 403
  • Page 404 404
  • Page 405 405
  • Page 406 406
  • Page 407 407
  • Page 408 408
  • Page 409 409
  • Page 410 410
  • Page 411 411
  • Page 412 412
  • Page 413 413
  • Page 414 414
  • Page 415 415
  • Page 416 416
  • Page 417 417
  • Page 418 418
  • Page 419 419
  • Page 420 420
  • Page 421 421
  • Page 422 422
  • Page 423 423
  • Page 424 424
  • Page 425 425
  • Page 426 426
  • Page 427 427
  • Page 428 428
  • Page 429 429
  • Page 430 430
  • Page 431 431
  • Page 432 432
  • Page 433 433
  • Page 434 434
  • Page 435 435
  • Page 436 436
  • Page 437 437
  • Page 438 438
  • Page 439 439
  • Page 440 440
  • Page 441 441
  • Page 442 442
  • Page 443 443
  • Page 444 444
  • Page 445 445
  • Page 446 446
  • Page 447 447
  • Page 448 448
  • Page 449 449
  • Page 450 450
  • Page 451 451
  • Page 452 452
  • Page 453 453
  • Page 454 454
  • Page 455 455
  • Page 456 456
  • Page 457 457
  • Page 458 458
  • Page 459 459
  • Page 460 460
  • Page 461 461
  • Page 462 462
  • Page 463 463
  • Page 464 464
  • Page 465 465
  • Page 466 466
  • Page 467 467
  • Page 468 468
  • Page 469 469
  • Page 470 470
  • Page 471 471
  • Page 472 472
  • Page 473 473
  • Page 474 474
  • Page 475 475
  • Page 476 476
  • Page 477 477
  • Page 478 478
  • Page 479 479
  • Page 480 480
  • Page 481 481
  • Page 482 482
  • Page 483 483
  • Page 484 484
  • Page 485 485
  • Page 486 486
  • Page 487 487
  • Page 488 488
  • Page 489 489
  • Page 490 490
  • Page 491 491
  • Page 492 492

Adobe Illustrator CS User manual

Category
Desktop publishing software
Type
User manual
This manual is also suitable for

Ask a question and I''ll find the answer in the document

Finding information in a document is now easier with AI