Adobe 65010248 Scripting Guide - Page 38

Combining path point types, Shapes

Page 38 highlights

CHAPTER 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.

  • 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
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
.