
C
HAPTER
4: Scripting with AppleScript
Creating paths and shapes
38
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}
--giving the direction points the same value as the
--anchor point creates a straight line segment
set newPoint to make new path point of lineRef with properties
{anchor:{220, 475},left direction:{220, 475},right direction:{220, 475},
point type:corner}
set newPoint2 to make new path point of lineRef with properties
{anchor:{375, 300},left direction:{375, 300},right direction:{375, 300},
point type:corner}
--giving the direction points the different values
--creates a curve
set newPoint3 to make new path point of lineRef with properties
{anchor:{220, 300},left direction:{180, 260},right direction:{240, 320},
point type:corner}
end tell
Combining path point types
The following script sample creates a path with three points, by combining the entire path property with a
path
point
object:
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},{375, 300}}
set newPoint to make new path point of lineRef with properties
{anchor:{220, 300},left direction:{180, 260},right direction:{240, 320},
point type:corner}
end tell
Shapes
To create a shape, you use the object that corresponds to the shape’s name (like
ellipse
,
rectangle
, or
polygon
), and use the object’s properties to specify the shape’s position, size, and other information like
the number of sides in a polygon.
Remember:
➤
The scripting engine processes all measurements and page coordinates as points. For details, see
“Measurement units” on page 29
.
➤
x and y coordinates are measured from the bottom-left corner of the document, as indicated in the
Info panel in the Illustrator application. For details, see
“Page-item positioning and dimensions” on
page 29
.