Creating New Objects; Working With Selections - Adobe 65010248 - Illustrator CS4 - PC Manual

Scripting guide
Hide thumbs Also See for 65010248 - Illustrator CS4 - PC:
Table of Contents

Advertisement

C
6: Scripting with VBScript
HAPTER
In the script below, the variable
script, since this script includes a reference to a layer:
Set documentRef = appRef.ActiveDocument
Set pageItemRef = documentRef.Layers(1).PageItems(1)
VBScript indexes start at 1 for object collections; however, VBScript allows you to specify whether array
indexes start at 1 or 0. For information on specifying the index start number for arrays, see any VBScript
textbook or tutorial.

Creating new objects

You can use a script to create new objects. To create objects that are available from collection objects, use
the collection object's
Set myDoc = appRef.Documents.Add()
Set myLayer = myDoc.Layers.Add()
Some collection objects do not have an
use the
CreateObject
the variable name
Set newColor = CreateObject ("Illustrator.CMYKColor")

Working with selections

When the user makes a selection in a document, the selected objects are stored in the document's
selection
Set appRef = CreateObject ("Illustrator.Application")
Set documentRef = appRef.ActiveDocument
selectedObjects = documentRef.Selection
Depending on what is selected, the
get or manipulate the properties of the selected art items, you must retrieve the individual items in the
array. To find out an object's type, use the
The following sample gets the first object in the array, then displays the object's type:
Set appRef = CreateObject ("Illustrator.Application")
Set documentRef = appRef.ActiveDocument
selectedObjects = documentRef.Selection
Set topObject = selectedObjects(0)
MsgBox(topObject.Typename)
The
MsgBox
(File > Scripts).
The first object in a selection array is the selected object that was last added to the page, not the last object
selected.
Selecting artwork objects
To select an artwork object, use the object's
pageItemRef
method:
Add
method. For example, the following code creates a new
:
newColor
property. To access all selected objects in the active document:
method does not display a dialog when the script is run from the Illustrator Scripts menu
will not necessarily refer to the same object as the above
method. To create an object of this type, define a variable and
Add
property value can be an array of any type of art objects. To
selection
property.
typename
property.
Selected
Accessing and referencing objects 50
object using
CMYKColor

Advertisement

Table of Contents
loading

This manual is also suitable for:

Illustrator cs4

Table of Contents