Adobe 65010248 Scripting Guide - Page 35
Obtaining objects from documents and layers, Creating new objects, Working with selections
![]() |
UPC - 883919156484
View all Adobe 65010248 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 35 highlights
CHAPTER 4: Scripting with AppleScript Object references 35 each consecutive make command. (Choose Event Log at the bottom of the Script Editor window.) Notice that both commands return the same object reference: path item 1 of layer 1 of document 1; therefore, the last line resolves to: set selection of document 1 to {path item 1 of layer 1 of document 1, path item 1 of layer 1 of document 1} A better approach is to reference the objects by name: tell application "Adobe Illustrator" set newDocument to make new document make new rectangle in newDocument with properties {name:"rectangle"} make new star in newDocument with properties {name:"star"} set selection of newDocument to {path item "rectangle" of newDocument, path item "star" of newDocument} end tell This example illustrates the need to uniquely identify objects in AppleScript scripts. We recommend that you assign names or variables to objects you need to access at a later time, as there is no guarantee you are accessing the objects you expect when accessing them by index. Obtaining objects from documents and layers This script references an object as part of a document: -- Get reference for first page item of document 1 tell application "Adobe Illustrator" set pageItemRef to page item 1 of document 1 end tell In the following script, the pageItemRef variable does not necessarily refer to the same object as in the previous script, because this script includes a reference to a layer: -- Get reference for first page item of layer 1 of document 1 tell application "Adobe Illustrator" set pageItemRef to page item 1 of layer 1 of document 1 end tell Creating new objects To create a new object in AppleScript, use the make command. Working with selections When the user makes a selection in a document, the selected objects are stored in the document's selection property. To access all selected objects in the active document: tell application "Adobe Illustrator" set myDoc to current document set selectedObjects to selection of myDoc end tell
![](/manual_guide/products/adobe-65010248-scripting-guide-414e49c/35.png)