Adobe 65010248 Scripting Guide - Page 28

VBScript, Selected objects, Selecting text, Selecting art items, Referring to selected art items

Page 28 highlights

CHAPTER 3: Scripting Illustrator Working with objects 28 VBScript To refer to a path items object in a document: Documents(1).PathItems(1) To refer to a path items object in a layer: Documents(1).Layers(1).PathItems(1) For more examples of collection-item containers, see the document object Elements table in Adobe Illustrator CS4 Scripting Reference: AppleScript or the Properties table in Adobe Illustrator CS4 Scripting Reference: JavaScript or Adobe Illustrator CS4 Scripting Reference: VBScript. A diagram of the Illustrator CS4 object model is in "The Illustrator Scripting Object Model" on page 17. Selected objects Sometimes, you want to write scripts that act on the currently selected object or objects. For example, you might want to apply formatting to selected text or change a selected path's shape. Selecting text To select text, use the select command or method of the text range object. Selecting art items You can select an art object (like graph items, mesh items, raster items, and symbol items) by setting its selected property to true. (In AppleScript, selected is a property of the page items object.) Referring to selected art items To refer to all currently selected objects in a document, use the document object's selection property. To work with the objects in the selection array, you must determine their type, so you will know which properties and methods or commands you can use with them. In JavaScript and VBScript, each artwork object type has a read-only typename property that you can use to determine the object's type. In AppleScript, use the class property. Notes on renaming objects stored in the application's panels Several objects can be renamed; that is, their name property is writeable. The following types of objects can be sorted alphabetically in the corresponding Illustrator panel. If a script modifies the name of such an object, references to that object by index can become invalid. Brush Gradient Graphic Style Pattern Swatch Symbol Variable

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57

C
HAPTER
3: Scripting Illustrator
Working with objects
28
VBScript
To refer to a
path
items
object in a document:
Documents(1).PathItems(1)
To refer to a
path
items
object in a layer:
Documents(1).Layers(1).PathItems(1)
For more examples of collection-item containers, see the
document
object Elements table in
Adobe
Illustrator CS4 Scripting Reference: AppleScript
or the Properties table in
Adobe Illustrator CS4 Scripting
Reference: JavaScript
or
Adobe Illustrator CS4 Scripting Reference: VBScript
. A diagram of the Illustrator CS4
object model is in
The Illustrator Scripting Object Model
” on page 17
.
Selected objects
Sometimes, you want to write scripts that act on the currently selected object or objects. For example, you
might want to apply formatting to selected text or change a selected path’s shape.
Selecting text
To select text, use the
select
command or method of the
text
range
object.
Selecting art items
You can select an art object (like graph items, mesh items, raster items, and symbol items) by setting its
selected
property to
true
. (In AppleScript,
selected
is a property of the
page
items
object.)
Referring to selected art items
To refer to all currently selected objects in a document, use the
document
object’s
selection
property. To
work with the objects in the selection array, you must determine their type, so you will know which
properties and methods or commands you can use with them. In JavaScript and VBScript, each artwork
object type has a read-only
typename
property that you can use to determine the object’s type. In
AppleScript, use the
class
property.
Notes on renaming objects stored in the application’s panels
Several objects can be renamed; that is, their
name
property is writeable. The following types of objects can
be sorted alphabetically in the corresponding Illustrator panel. If a script modifies the name of such an
object, references to that object by index can become invalid.
Brush
Gradient
Graphic Style
Pattern
Swatch
Symbol
Variable