Adobe 65010248 Scripting Guide - Page 37

Threaded frames make one story object, Creating paths and shapes, Paths

Page 37 highlights

CHAPTER 4: Scripting with AppleScript Creating paths and shapes 37 Threaded frames make one story object Threaded frames make a single story object. To observe this, run the following AppleScript after running the script in "Threaded frames" on page 36. display dialog ("There are " & (count(text frames of current document)) & " text frames.") display dialog("There are " & (count(stories of current document)) & " stories.") Creating paths and shapes This section explains how to create items that contain paths. Paths To create line or a freeform path, specify a series of path points, as a series of x-y coordinates or path point objects. Using x-y coordinates limits the path to straight segments. To created a curved path, you must create path point objects. A path can comprise a combination of page coordinates and path point objects. Specifying a series of x-y coordinates To specify a path using page-coordinate pairs, use the entire path property of the path items object. The following script specifies three pairs of x-y coordinates, to create a path with three points: tell application "Adobe Illustrator" set docRef to make new document -- set stroked to true so we can see the path set lineRef to make new path item in docRef with properties {stroked:true} set entire path of lineRef to {{220, 475},{200, 300},{375, 300}} end tell Using path point objects To create a path point object, you must define three values for the point. ➤ A fixed anchor point, which is the point on the path. ➤ A pair of direction points-left direction and right direction-which allow you to control the path segment's curve. You define each property as an array of page coordinates in the format [x, y]: ➤ If all three properties of a path point object have the same coordinates, and the properties of the next path point in the line are equal to each other, you create a straight-line segment. ➤ If two or more properties in a path point object have different values, the segment connected to the point is curved. To create a path or add points to an existing path using path point objects, create a path item object, then add the path points as child objects in the path item:

  • 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
4: Scripting with AppleScript
Creating paths and shapes
37
Threaded frames make one story object
Threaded frames make a single
story
object. To observe this, run the following AppleScript after running
the script in
Threaded frames
” on page 36
.
display dialog ("There are " & (count(text frames of current document)) & " text frames.")
display dialog("There are " & (count(stories of current document)) & " stories.")
Creating paths and shapes
This section explains how to create items that contain paths.
Paths
To create line or a freeform path, specify a series of path points, as a series of x-y coordinates or
pathpoint
objects.
Using x-y coordinates limits the path to straight segments. To created a curved path, you must create
pathpoint
objects. A path can comprise a combination of page coordinates and
path
point
objects.
Specifying a series of x-y coordinates
To specify a path using page-coordinate pairs, use the
entire
path
property of the
path
items
object.
The following script specifies three pairs of x-y coordinates, to create a path with three points:
tell application "Adobe Illustrator"
set docRef to make new document
-- set stroked to true so we can see the path
set lineRef to make new path item in docRef with properties {stroked:true}
set entire path of lineRef to {{220, 475},{200, 300},{375, 300}}
end tell
Using path point objects
To create a
path
point
object, you must define three values for the point.
A fixed
anchor
point, which is the point on the path.
A pair of direction points—
left
direction
and
right
direction
—which allow you to control the
path segment’s curve.
You define each property as an array of page coordinates in the format [x, y]:
If all three properties of a
path
point
object have the same coordinates, and the properties of the next
path
point
in the line are equal to each other, you create a straight-line segment.
If two or more properties in a
path
point
object have different values, the segment connected to the
point is curved.
To create a path or add points to an existing path using
path
point
objects, create a
path
item
object,
then add the path points as child objects in the
path
item
: