Macromedia Illustrator - CS3 User Guide

SCRIPTING GUIDE
© 2007 Adobe Systems Incorporated. All rights reserved.
®
Adobe
Illustrator® CS3 Scripting Guide for Windows® and Mac OS®.
This publication and the information herein is furnished AS IS, 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, makes no warranty of any kind (express, implied, or statutory) with respect to this publication, and expressly disclaims any and all warranties of merchantability, fitness for particular purposes, and noninfringement of third party rights.
Any references to company names in sample templates are for demonstration purposes only and are not intended to refer to any actual organization.
Adobe, the Adobe logo, Illustrator, Photoshop, and InDesign are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States and/or other countries.
Apple, Mac, Macintosh, and Mac OS are trademarks of Apple Computer, Inc., registered in the United States and other countries. Microsoft, and Windows are either registered trademarks or trademarks of Microsoft Corporation in the United States and other countries. JavaScript and all Java-related marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. UNIX is a registered trademark of The Open Group.
All other trademarks are the property of their respective owners.
If this guide is distributed with software that includes an end user agreement, this guide, as well as the software described in it, is furnished under license and may be used or copied only in accordance with the terms of such license. Except as permitted by any such license, no part of this guide may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, recording, or otherwise, without the prior written permission of Adobe Systems Incorporated. Please note that the content in this guide is protected under copyright law even if it is not distributed with software that includes an end user license agreement.
The content of this guide 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 the informational content contained in this guide.
Adobe Systems Incorporated, 345 Park Avenue, San Jose, California 95110, USA.

Contents

1 Introduction ................................................................................................................................. 6
What is scripting? ........................................................................................................................................................................... 6
Why use scripting?................................................................................................................................................................... 6
What about actions? ............................................................................................................................................................... 7
Script support in Adobe Illustrator CS3.................................................................................................................................. 7
ExtendScript features ............................................................................................................................................................. 7
ExtendScript tools.................................................................................................................................................................... 7
Script file extensions ..................................................................................................................................................................... 8
Viewing sample scripts................................................................................................................................................................. 8
Viewing the object model........................................................................................................................................................... 8
Viewing the JavaScript object model ............................................................................................................................... 8
Viewing the AppleScript object model............................................................................................................................ 9
Viewing the VBScript object model................................................................................................................................... 9
Executing scripts...........................................................................................................................................................................10
Installing scripts in the Scripts menu..............................................................................................................................10
Executing scripts from the Other Scripts menu item................................................................................................10
Startup scripts (.jsx scripts only) .......................................................................................................................................10
Application-specific startup scripts folder..............................................................................................................10
General startup scripts folder......................................................................................................................................11
Changes since earlier versions.................................................................................................................................................11
Known Issues .................................................................................................................................................................................13
2 The Illustrator Scripting Object Model .................................................................................... 15
Object naming conventions.....................................................................................................................................................15
Top-level (containing) objects.................................................................................................................................................16
Application...............................................................................................................................................................................16
Document.................................................................................................................................................................................16
Layer ...........................................................................................................................................................................................17
The artwork tree............................................................................................................................................................................17
Art styles....................................................................................................................................................................................18
Color objects............................................................................................................................................................................18
Text objects ...................................................................................................................................................................................19
Text frames...............................................................................................................................................................................19
Text geometry...................................................................................................................................................................19
Objects that represent text content................................................................................................................................20
Text ranges.........................................................................................................................................................................21
Text styles .................................................................................................................................................................................21
Dynamic objects and symbols ................................................................................................................................................21
Transformations............................................................................................................................................................................22
3 Scripting Illustrator ................................................................................................................... 23
Launching and quitting Illustrator from a script...............................................................................................................23
Launching and activating Illustrator...............................................................................................................................23
Quitting Illustrator .................................................................................................................................................................24
Working with objects .................................................................................................................................................................24
Getting the frontmost document or layer ....................................................................................................................24
3
Adobe Illustrator CS3
Scripting Guide Contents 4
Creating new objects............................................................................................................................................................25
Collection objects ..................................................................................................................................................................25
Selected objects .....................................................................................................................................................................26
Selecting text ....................................................................................................................................................................26
Selecting art items...........................................................................................................................................................26
Referring to selected art items....................................................................................................................................26
Notes on renaming objects stored in the application’s palettes..........................................................................26
Measurement units......................................................................................................................................................................27
Em space units ........................................................................................................................................................................27
Page item positioning and dimensions ...............................................................................................................................27
Art item bounds......................................................................................................................................................................28
Paths and shapes..........................................................................................................................................................................29
User interaction levels ................................................................................................................................................................29
Printing Illustrator documents ................................................................................................................................................30
4 Scripting with JavaScript .......................................................................................................... 31
Your first Illustrator script..........................................................................................................................................................31
Adding features to "Hello World".....................................................................................................................................32
Working with methods in JavaScript ....................................................................................................................................32
Accessing and referencing objects........................................................................................................................................33
Referencing the application object.................................................................................................................................33
Accessing objects in collections.......................................................................................................................................33
Creating new objects............................................................................................................................................................34
Working with selections ......................................................................................................................................................35
Selecting artwork objects .............................................................................................................................................35
Working with text frames..........................................................................................................................................................35
Threaded frames ....................................................................................................................................................................35
Threaded frames make a single story object.........................................................................................................36
Creating paths and shapes .......................................................................................................................................................36
Paths ...........................................................................................................................................................................................36
Specifying a series of x-y coordinates ......................................................................................................................36
Using pathPoint objects................................................................................................................................................37
Combining path point types .......................................................................................................................................38
Shapes........................................................................................................................................................................................39
Creating a rectangle .......................................................................................................................................................39
Creating a polygon..........................................................................................................................................................39
5 Scripting with AppleScript........................................................................................................ 40
Your first Illustrator script..........................................................................................................................................................40
Adding features to "Hello World".....................................................................................................................................41
Object references .........................................................................................................................................................................41
Obtaining objects from documents and layers ..........................................................................................................42
Creating new objects............................................................................................................................................................42
Working with selections ......................................................................................................................................................42
Selecting artwork objects .............................................................................................................................................43
Working with text frames..........................................................................................................................................................43
Threaded frames ....................................................................................................................................................................43
Threaded frames make a single story object.........................................................................................................44
Creating paths and shapes .......................................................................................................................................................44
Paths ...........................................................................................................................................................................................44
Specifying a series of x-y coordinates ......................................................................................................................44
Using path point objects...............................................................................................................................................44
Adobe Illustrator CS3
Scripting Guide 5
Combining path point types .......................................................................................................................................45
Shapes........................................................................................................................................................................................45
write-once access ............................................................................................................................................................46
Creating a rectangle .......................................................................................................................................................46
Creating a polygon..........................................................................................................................................................46
6 Scripting with VBScript ............................................................................................................. 47
Your first Illustrator script..........................................................................................................................................................47
Adding features to "Hello World".....................................................................................................................................48
Accessing and referencing objects........................................................................................................................................48
Obtaining objects from collections.................................................................................................................................48
Creating new objects............................................................................................................................................................49
Working with selections ......................................................................................................................................................49
Selecting artwork objects .............................................................................................................................................49
Working with text frames..........................................................................................................................................................50
Threaded frames ....................................................................................................................................................................50
Threaded frames make a single story object.........................................................................................................50
Creating paths and shapes .......................................................................................................................................................50
Paths ...........................................................................................................................................................................................50
Specifying a series of x-y coordinates ......................................................................................................................51
Using path point objects...............................................................................................................................................51
Combining path point types .......................................................................................................................................52
Shapes........................................................................................................................................................................................52
Creating a rectangle .......................................................................................................................................................52
Creating a polygon..........................................................................................................................................................52
Working with enumeration values.........................................................................................................................................53
Index ...........................................................................................................................................54
1

Introduction

This guide describes the scripting interface to Adobe® Illustrator® CS3. It contains the following sections:
This introduction, which describes scripting support in Adobe Illustrator CS3, and lists changes to the
scripting interface since the previous release.
“The Illustrator Scripting Object Model” on page 15, which describes the Illustrator document object
model.
“Scripting Illustrator” on page 23, which provides an overview of how to use scripts to program Adobe
Illustrator CS3.
“Scripting with JavaScript” on page 31, which provides information about scripting Illustrator using
JavaScript.
“Scripting with AppleScript” on page 40, which provides information about scripting Illustrator using
AppleScript.
“Scripting with VBScript” on page 47, which provides information about scripting Illustrator using
VBScript.
If you are new to scripting or would like basic information about scripting and how to use the different scripting languages, see Adobe Introduction to Scripting.

What is scripting?

A script is a series of commands that tells Illustrator to perform one or more tasks. These tasks can be simple, and affect only a single object in the current document; or complex, and affect objects in all of your Illustrator documents. The tasks might even involve other applications, such as word processors, spreadsheets, and database management programs.
The building blocks of scripting correspond for the most part to the Illustrator tools, menus, palettes, and dialog boxes with which you are already an expert. If you know what you’d like Illustrator to do, you can write a script to do it.

Why use scripting?

Graphic design is a field characterized by creativity, but aspects of the actual work are anything but creative. 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 image setting service provider often reduce the time you have available for doing creative work.
With a small investment of time and effort—perhaps no more than you’d spend training an assistant—you can learn to write short, simple scripts that perform repetitive tasks for you. As your scripting skills grow, you can move on to more complex scripts that work all night while you’re sleeping.
Scripting can also enhance your creativity by quickly performing tasks you might not have time to try. 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 accesses 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.
6
Adobe Illustrator CS3
Scripting Guide Introduction 7

What about actions?

Actions and scripts are both ways of automating repetitive tasks, but they work very differently.
Actions use a program’s 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 program’s 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, such as changing the stroke type of rectangles but not ellipses. 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.

Script support in Adobe Illustrator CS3

Illustrator scripting supports AppleScript and JavaScript scripts for Mac OS, or VBScript and JavaScript scripts for Windows.
Note: Additionally, Adobe scripting-enabled applications, including Illustrator, support ExtendScript,
Adobe’s extended implementation of ECMA JavaScript. ExtendScript files are distinguished by the
.jsx extension. Giving your JavaScript files a .jsx extension allows you to take advantage of the
ExtendScript features and tools.

ExtendScript features

ExtendScript offers all standard JavaScript features, plus a development and debugging
environment, the ExtendScript Toolkit (ESTK). The ESTK is installed with all scriptable Adobe applications.
The ESTK includes an Object Model Viewer that contains complete documentation of the
methods and properties of JavaScript objects.
Note: For information on accessing the ESTK and the Model Viewer, see “Viewing the JavaScript object
model” on page 8.

ExtendScript tools

ExtendScript also provides various tools and utilities such as:
A localization utility
Tools that allow you to combine scripts and direct them to particular applications
Platform-independent file and folder representation
Tools for building user interfaces to your scripts
A messaging framework that allows you to send and receive scripts and data among
scripting-enabled Adobe applications
For details of these and additional features, see the JavaScript Tools Guide.
Adobe Illustrator CS3
Scripting Guide Introduction 8

Script file extensions

For a file to be recognized by Adobe Illustrator CS3 as a valid script file, the file must have the correct file name extension:
Script Type File Type Extension Platform
AppleScript compiled script
OSAS file
JavaScript
text
ExtendScript
VBScript text

Viewing sample scripts

Adobe provides sample scripts for many objects, properties, and methods in the Illustrator CS3 DOM. You can view script samples in two locations:
In the /Scripting/Sample Scripts folder in your Illustrator CS3 installation directory
In the Adobe Illustrator CS3 scripting reference for your scripting language, which is located in the
/Scripting/Documentation folder in your Illustratator CS3 installation directory.

Viewing the object model

The supported scripting languages each provide a facility for viewing the scripting objects defined by Illustrator, with reference details.
.scpt
.js .jsx
.vbs
(none)
Mac OS
Mac OS & Windows
Windows

Viewing the JavaScript object model

To view the JavaScript object model for Illustrator:
1. Start the ExtendScript Toolkit (ESTK).
Note: In a default Adobe installation, the ESTK is in the following location:
In Mac OS:
system drive:Applications:Utilities:Adobe Utilities: ExtendScript Toolkit 2
In Windows:
system drive\Program Files\Adobe\Adobe Utilities\ ExtendScript Toolkit 2
2. In the ESTK, choose Help > Illustrator CS3.
Note: Several extended sample scripts are available in the
your Illustrator CS3 installation directory.
You can also view script samples and information about individual classes, objects, properties, methods and parameters in the Adobe Illustrator CS3 JavaScript Reference, which is found in the
/Scripting/Documentation folder in your Illustrator CS3 installation directory.
/Scripting/Sample Scripts folder in
Adobe Illustrator CS3
Scripting Guide Introduction 9

Viewing the AppleScript object model

Apple provides a Script Editor with all Mac OS systems. You can use Script Editor to view the AppleScript dictionary that describes Illustrator objects and commands.
Note: For details of how to use the Script Editor, see Script Editor Help.
1. Start Script Editor.
Note: 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. Choose File > Open Dictionary. Script Editor displays an Open File dialog.
3. In the Open File dialog, find and select Illustrator, and then click OK.
Script Editor displays a list of the Illustrator objects and commands, which includes the properties and elements associated with each object and the parameters for each command.
Note: Several extended sample scripts are available in the
your Illustrator CS3 installation directory.
You can also view script samples and information about individual classes, objects, properties, methods and parameters in the Adobe Illustrator CS3 AppleScript Reference, which is found in the
:Scripting:Documentation folder in your Illustrator CS3 installation directory.

Viewing the VBScript object model

VBScript provides a type library that you can use to view Illustrator object properties and methods. This procedure explains how to view the type library through any Microsoft Office program. Your VBScript editor most likely provides access to the library. Consult your editor’s Help for information.
1. In any Microsoft Office application, choose Tools > Macro > Visual Basic Editor.
2. In the Visual Basic Editor, choose Tools > References.
3. In the dialog that appears, select the check box for Adobe Illustrator CS3 Type Library, and then click OK.
4. Turn on the Adobe Illustrator CS3 Type Library option from the list of available references and click OK.
5. Choose View > Object Browser to display the Object Browser window.
6. Choose "Illustrator" from the list of open libraries in the top-left pull-down menu of the Object Browser window.
:Scripting:Sample Scripts folder in
Note: Several extended sample scripts are available in the
your Illustrator CS3 installation directory.
You can also view script samples and information about individual classes, objects, properties, methods and parameters in the Adobe Illustrator CS3 VBScript Reference, which is found in the
/Scripting/Documentation folder in your Illustrator CS3 installation directory.
/Scripting/Sample Scripts folder in
Adobe Illustrator CS3
Scripting Guide Introduction 10

Executing scripts

The Illustrator interface includes a Scripts menu (File > Scripts) that provides quick and easy access to your scripts.
Scripts can be listed directly as menu items that run when you select them. See “Installing scripts in the
Scripts menu” on page 10.
You can also navigate from the menu to any script in your file system, and then run the script. See
“Executing scripts from the Other Scripts menu item” on page 10
.
You can also have JavaScript scripts with a application. For information, see “Startup scripts (.jsx scripts only)” on page 10
.jsx extension start automatically when you launch the

Installing scripts in the Scripts menu

To include a script in the Scripts menu (File > Scripts), save the script in the Scripts folder, which is located in the /Illustrator CS3/ Presets folder in your Illustrator CS3 installation directory. The script’s file name, minus the file extension, appears in the Scripts menu.
Note: Scripts that you add to the Scripts folder while Illustrator is running do not appear in the Scripts
menu until the next time you launch Illustrator.
Any number of scripts can be installed in the Scripts menu. If you have a large collection of scripts, use subfolders in the Scripts folder to help organize the scripts in the Scripts menu. Each subfolder is displayed as a separate submenu containing the scripts in that subfolder.

Executing scripts from the Other Scripts menu item

The Other Scripts item at the end of the Scripts menu (File > Scripts > Other Scripts) allows you to execute scripts that are not installed in the Scripts folder.
Selecting Other Scripts displays a Browse dialog, which you use to navigate to a script file. When you select the file, the script is executed.
.
Note: Only files that are of one of the supported file types are displayed in the browse dialog. For
information, see “Script support in Adobe Illustrator CS3” on page 7

Startup scripts (.jsx scripts only)

JavaScript scripts with a .jsx file extension can be installed in one of two folders so that the scripts run automatically when you launch Illustrator and each time you run a script. The folders are:
An application-specific startup scripts folder, which contains scripts for Illustrator CS3
A general startup scripts folder, which contains scripts that run automatically when you start any
Creative Suite 3 application
Application-specific startup scripts folder
You must place application-specific startup scripts in a folder named Startup Scripts, which you create in the Illustrator installation directory.
.
Adobe Illustrator CS3
Scripting Guide Introduction 11
For example, when Illustrator CS3 is installed to its default location, you would create the Startup
Scripts
In Windows:
folder at:
C:\Program Files\Adobe\Adobe Illustrator CS3\Startup Scripts\
In Mac OS:
/Applications/Adobe Illustrator CS3/Startup Scripts/
Note: JavaScript scripts with a .jsx extension placed in the Startup Scripts folder run automatically
when:
The application is launched.
Any JavaScript file is selected from the Scripts menu (File > Scripts).
General startup scripts folder
The general startup scripts folder contains scripts that run automatically when you start any Creative Suite 3 application. You create the folder in the following location:
In Windows:
Program Files/Common Files/Adobe/Startup Scripts CS3/Illustrator
In Mac OS:
:Library:Application Support:Adobe:Startup Scripts CS3:Illustrator
Note: If a script in the general startup folder is meant to be executed only by Illustrator, the script must
include the ExtendScript
#target directive (#target illustrator) or code such as the
following:
if( BridgeTalk.appName == "illustrator" ) { //continue executing script }
For additional details, see the JavaScript Tools Guide.

Changes since earlier versions

The following changes have been made to the scripting object model to support features in Adobe Illustrator CS3:
Create documents using the document preset object, which contains properties for color mode,
height and width, preview mode, title, and other document-defining characteristics:
JavaScript: app.documents.addDocument(), uses new object documentPreset;
app.startupPresetsList gives available presets; app.getPresetSettings() returns a documentPreset object.
VBScript: App.Documents.AddDocument, uses new object DocumentPreset;
App.StartupPresetsList gives available presets; App.GetPresetSettings returns a DocumentPreset object.
AppleScript: add document command, uses new object document preset; the startup
presets property gives available presets, get preset settings command returns a document preset
Undo and redo operations:
object.
Adobe Illustrator CS3
Scripting Guide Introduction 12
JavaScript: app.undo(), app.redo()
VBScript: App.Undo(), App.Redo()
AppleScript: undo and redo commands
Clipboard operations, previously available only in AppleScript, are supported in VBScript and
JavaScript. These methods belong to the
JavaScript: app.cut(), app.copy(), app.paste()
VBScript: App.Cut, App.Copy, App.Paste
Additional control of color:
JavaScript: app.loadColorSettings(), which loads color settings from a specified file;
application object but act upon the current selection:
app.colorSettingsList gives available files.
VBScript: App.LoadColorSettings; App.ColorSettingsList gives available files.
AppleScript: load color settings command; the color settings property gives available
files.
New properties for raster item objects
JavaScript: rasterItem.overprint, rasterItem.colorizedGrayscale,
rasterItem.transparent, rasterItem.channels, rasterItem.bitsPerChannel, rasterItem.colorants
VBScript: RasterItem.Overprint, RasterItem.ColorizedGrayscale,
RasterItem.Transparent, RasterItem.Channels, RasterItem.BitsPerChannel, RasterItem.Colorants
AppleScript: bits per channel, channels, colorants, colorized, overprint,
transparent
Capturing clipping-area content to a raster file:
JavaScript: document.imageCapture(); uses new object imageCaptureOptions
VBScript: Document.ImageCapture; uses new object ImageCaptureOptions
AppleScript: image capture command, uses new object image capture options
Merging of graphic styles:
JavaScript: graphicStyle.mergeTo()
VBScript: GraphicStyle.MergeTo
AppleScript: merge command
Support for indicating the length (in points) of a path:
JavaScript: pathItem.length
VBScript: PathItem.Length
AppleScript: length of path item
XMP metadata, which names the XMP metadata packet associated with a document:
JavaScript: document.XMPString
VBScript: Document.XMPString
AppleScript: XMP string
Additional support of Adobe Photoshop
®
files:
Adobe Illustrator CS3
Scripting Guide Introduction 13
JavaScript: openOptionsPhotoshop.preserveHiddenLayers,
openOptionsPhotoshop.layerComp
VBScript: OpenOptionsPhotoshop.PreserveHiddenLayers,
OpenOptionsPhotoshop.LayerComp
● AppleScript: properties of Photoshop options: preserve hidden layers, layer comp
New method or command for obtaining detailed PPD file information:
JavaScript: app.getPPDFileInfo() (also, case usage in printerInfo.pPDInfo changed to
printerInfo.PPDInfo)
VBScript: App.GetPPDFileInfo
AppleScript: get PPD info command
Additional support for exporting to Flash SWF format:
JavaScript: additional properties for exportOptionsFlash
VBScript: additional properties for ExportOptionsFlash
AppleScript: additional properties of Flash export options
AutoCAD support:
JavaScript: preferences.AutoCADFileOptions, new object AutoCADFileOptions
VBScript: Preferences.AutoCADFileOptions, new object AutoCADFileOptions
AppleScript: AutoCAD file options of Illustrator preferences, new object AutoCAD
options
Expanded support for clipping artwork when exporting to a Flash file allow you to specify whether to
clip the art object, the artboard, or the crop area:
JavaScript: exportOptionsGIF.artClipping (replaces
exportOptionsGIF.artBoardClipping)
VBScript: ExportOptionsGIF.ArtClipping (replaces
ExportOptionsGIF.ArtBoardClipping)
AppleScript: art clipping (replaces artboard clipping)
New tracing options property allows you to ignore white fill color.
JavaScript: tracingOptions.ignoreWhite
VBScript: TracingOptions.IgnoreWhite
AppleScript: ignore white

Known Issues

Scripts that create, save and then close a large number of Illustrator files should periodically quit and
relaunch Illustrator. The recommended maximum number of files to process before quitting and relaunching Illustrator is:
In Windows: 500 files
In Mac OS: 1000 files
Note: For information on quitting and relaunching Illustrator, see “Launching and activating
Illustrator” on page 23 and “Quitting Illustrator” on page 24.
Adobe Illustrator CS3
Scripting Guide Introduction 14
The "An Illustrator error occurred: 1346458189 ("PARM")" alert may be popped when badly written
scripts are repeatedly run in Illustrator from the ExtendScript Toolkit.
Scripters need to be very careful about variable initialization and namespace conflict when pushing a batch of Illustrator scripts over and over again for execution in Illustrator via the ExtendScript Toolkit (ESTK) in a single Illustrator session. Each script run is executed within the same persistent ExtendScript engine within Illustrator.
The ESTK debugger uses BridgeTalk to communicate with Illustrator. A single global, persistent ExtendScript engine inside Illustrator handles all BridgeTalk communications. The net effect is that the state of the ExtendScript engine is cumulative to all the scripts that ran previously. Issues with script code that may cause this problem are:
Reading uninitialized variables.
Global namespace conflicts, such as when two globals from differents scripts are clobbering each
other.
2

The Illustrator Scripting Object Model

A good understanding of the Illustrator object model will improve your scripting abilities. The figure below shows the containment hierarchy of the object model, starting with the
layer and group item classes can contain nested objects of the same class which can, in turn,
the contain additional nested objects.
application object. Note that
Illustrator scripting object model
Note: In addition to this application-specific object model, JavaScript provides certain utility objects, such
File and Folder objects, which give you operating-system-independent access to the file
as the system. For details, see the JavaScript Tools Guide.

Object naming conventions

There is a single object model for the Illustrator scripting interface, but the actual object names vary slightly in the different scripting languages:
AppleScript names are all lower case, and individual words are separated by a space. For example:
graphic style
VBScript names are capitalized, and additional words in the name are indicated by uppercase initial
letters. For example:
GraphicStyle
15
Adobe Illustrator CS3
Scripting Guide The Illustrator Scripting Object Model 16
JavaScript names begin with lowercase letters, and additional words in the name are indicated by
uppercase initial letters. For example:
graphicStyle
This chapter uses generic object and property names, but you can easily apply these conventions to determine the corresponding language-specific names.
Note: In the following sections, properties and methods are displayed in italics. Object names are
displayed in
courier font.

Top-level (containing) objects

Use these objects to access global information about the Illustrator application or an individual document.

Application

The properties of the application object give your script access to global values, such as:
User preferences, which a user sets interactively in the Illustrator application by using the
Preferences dialog (Edit > Preferences)
System information such as installed fonts (the text fonts property) and printers (the printer list
property)
Additionally, there are properties that provide application-specific information and higher-level information about any open documents.
Application information such as the installation path, the version, and whether Illustrator is currently
visible
The current active document; that is, the art canvas that is currently displayed and accepting user input
All open documents
application
example:
Open files
Undo and redo transactions
Quit Illustrator

Document

The document object, which your scripts can create or access through the application object, represents an art canvas or loaded Illustrator file. The document’s content. For example:
object methods or commands allow your script to perform application-wide actions. For
document object properties give you access to the
The current selection, or art objects that the user has selected in the document
All of the contained art objects, called page items, that make up the artwork tree
Art objects of particular types, such as symbols and text frames
All of the layers, and the currently active layer
Adobe Illustrator CS3
Scripting Guide The Illustrator Scripting Object Model 17
Document properties also tell you about the state of the document itself; for example:
User settings for the document such as ruler units
Whether the document has been saved since the last alteration of content
The path of the associated file
document object methods allow your scripts to act on the document. For example:
The
Save to an Illustrator file or save as the various supported file formats
Activate or close a document
Print the document; your scripts can select a printer by referencing a print options object or
reference available printers through the application object’s printer list property

Layer

The layer object provides access to the contents, or artwork tree, of a specific layer. You access the layer object through the about, the layer, such as:
Whether the layer is visible or locked
document object. The layer object properties provide access to, or information
The layer opacity (overall transparency) and z order position (position in the stacking order)
Art creation preferences for the layer, such as artwork knockout and blending mode

The artwork tree

The content of an Illustrator document is called the artwork tree. Artwork is represented by the following objects:
The compound path item object
The graph item object
The legacy text item object
The mesh item object
The path item object
The placed item object
The plugin item object
The raster item object
The symbol item object (See “Dynamic objects and symbols” on page 21.)
The text frame object
Your scripts can access and manipulate art objects through collections in the objects. There are two types of art object collections:
document and layer
Collection objects that correspond to each individual artwork object type, such as the graph items
object or the
The page items object, which includes art objects of all types.
Additionally, you can use the
mesh items object.
group item object to reference a grouped set of art items.
Loading...
+ 38 hidden pages