EDOBE XDOM TPC Technical Information Page 56

  • Download
  • Add to my manuals
  • Print
  • Page
    / 68
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 55
CHAPTER 6: Scripting with VBScript Accessing and referencing objects 56
Adding features to “Hello World”
Next, we create a new script that makes changes to the Illustrator document you created with your first
script. The second script demonstrates how to:
X Get the active document.
X Get the width of the active document.
X Resize the text frame item to match the document’s width.
If you closed the Illustrator document without saving it, run your first script again to create a new
document.
Follow these steps:
1. Copy the following script into your text editor, and save the file.
Set appRef = CreateObject("Illustrator.Application")
'Get the active document
Set documentRef = appRef.ActiveDocument
Set sampleText = documentRef.TextFrames(1)
' Resize the TextFrame item to match the document width
sampleText.Width = documentRef.Width
sampleText.Left = 0
2. Run the script.
Accessing and referencing objects
When you write a script, you must first decide which file, or Document, the script should act on. Through
the
Application object, the script can create a new document, open an existing document, or act on a
document that is already open.
The script can create new objects in the document, operate on objects that the user selected, or operate
on objects in one of the object collections. The following sections illustrate techniques for accessing,
referencing, and manipulating Illustrator objects.
Obtaining objects from collections
Generally, to obtain a reference to a specific object, you can navigate the containment hierarchy. For
example, to use the
myPath variable to store a reference to the first PathItem in the second layer of the
active document:
Set myPath = appRef.ActiveDocument.Layers(2).PathItems(1)
The following scripts demonstrate how to reference an object as part of a document:
Set documentRef = appRef.ActiveDocument
Set pageItemRef = documentRef.PageItems(1)
Page view 55
1 2 ... 51 52 53 54 55 56 57 58 59 60 61 ... 67 68

Comments to this Manuals

No comments