Adobe 65010248 Scripting Guide - Page 54

Creating a polygon, Working with enumeration values

Page 54 highlights

CHAPTER 6: Scripting with VBScript Working with enumeration values 54 Creating a polygon Consider the following sample: Set appRef = CreateObject("Illustrator.Application") Set frontDocument = appRef.ActiveDocument ' Create a new polygon with ' top = 144, left side = 288, width = 72, height = 144 Set newPolygon = frontDocument.PathItems.Polygon(144,288,72,7) The sample creates a polygon with these properties: ➤ The center point of the object is inset 2 inches (144 points) on the horizontal axis and 4 inches (288 points) on the vertical axis. ➤ The length of the radius from the center point to each corner is 1 inch (72 points). ➤ The polygon has 7 sides. Working with enumeration values Properties that use enumeration values in VBScript use a numeral rather than a text value. For example, the Orientation property of the TextFrame object specifies whether text content in the text frame is horizontal or vertical. The property uses the aiTextOrientation enumeration, which has two possible values, aiHorizontal and aiVertical. To find the numeral values of enumerations, use either of the following: ➤ The object browser in your scripting editor environment. See "Viewing the VBScript object model" on page 9. ➤ The Adobe Illustrator CS4 Scripting Reference: VBScript, which lists the numeral values directly after the constant value in the "Enumerations" chapter at the end of the book. The following example is from that table: Enumeration type AiTextOrientation Values aiHorizontal = 0 aiVertical = 1 What it means The orientation of text in a text frame The following sample specifies vertical text orientation: Set appRef = CreateObject ("Illustrator.Application") Set docRef = appRef.Documents.Add Set textRef = docRef.TextFrames.Add textRef.Contents = "This is some text content." textRef.Left = 50 textRef.Top = 700 textRef.Orientation = 1 Generally, it is considered good scripting practice to place the text value in a comment following the numeral value, as in the following sample statement: textRef.Orientation = 1 ' aiVertical

  • 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
6: Scripting with VBScript
Working with enumeration values
54
Creating a polygon
Consider the following sample:
Set appRef = CreateObject("Illustrator.Application")
Set frontDocument = appRef.ActiveDocument
' Create a new polygon with
' top = 144, left side = 288, width = 72, height = 144
Set newPolygon = frontDocument.PathItems.Polygon(144,288,72,7)
The sample creates a polygon with these properties:
The center point of the object is inset 2 inches (144 points) on the horizontal axis and 4 inches
(288 points) on the vertical axis.
The length of the radius from the center point to each corner is 1 inch (72 points).
The polygon has 7 sides.
Working with enumeration values
Properties that use enumeration values in VBScript use a numeral rather than a text value. For example,
the
Orientation
property of the
TextFrame
object specifies whether text content in the text frame is
horizontal or vertical. The property uses the
aiTextOrientation
enumeration, which has two possible
values,
aiHorizontal
and
aiVertical
.
To find the numeral values of enumerations, use either of the following:
The object browser in your scripting editor environment. See
Viewing the VBScript object model
” on
page 9
.
The
Adobe Illustrator CS4 Scripting Reference: VBScript
, which lists the numeral values directly after the
constant value in the “Enumerations” chapter at the end of the book. The following example is from
that table:
The following sample specifies vertical text orientation:
Set appRef = CreateObject ("Illustrator.Application")
Set docRef = appRef.Documents.Add
Set textRef = docRef.TextFrames.Add
textRef.Contents = "This is some text content."
textRef.Left = 50
textRef.Top = 700
textRef.Orientation = 1
Generally, it is considered good scripting practice to place the text value in a comment following the
numeral value, as in the following sample statement:
textRef.Orientation = 1 ' aiVertical
Enumeration type
Values
What it means
AiTextOrientation
aiHorizontal = 0
aiVertical = 1
The orientation of text in a text frame