EDOBE XDOM TPC Technical Information Page 36

  • Download
  • Add to my manuals
  • Print
  • Page
    / 68
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 35
CHAPTER 4: Scripting with AppleScript Object references 36
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
Page view 35
1 2 ... 31 32 33 34 35 36 37 38 39 40 41 ... 67 68

Comments to this Manuals

No comments