Adobe 65010248 Scripting Guide - Page 52
Specifying a series of x-y coordinates, Using path point objects, object have the same coordinates
UPC - 883919156484
View all Adobe 65010248 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 52 highlights
CHAPTER 6: Scripting with VBScript Creating paths and shapes 52 Using x-y coordinates limits the path to straight segments. To created a curved path, you must create PathPoint objects. Your path can comprise a combination of page coordinates and PathPoint objects. Specifying a series of x-y coordinates To specify a path using page-coordinate pairs, use the SetEntirePath() method of the PathItems object. The following script specifies three pairs of x-y coordinates, to create a path with three points: Set appRef = CreateObject ("Illustrator.Application") Set firstPath = appRef.ActiveDocument.PathItems.Add firstPath.Stroked = True firstPath.SetEntirePath(Array(Array(220, 475),Array(375, 300),Array(200, 300))) Using path point objects To create a PathPoint 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 (Array (x,y)). ➤ If all three properties of a PathPoint object have the same coordinates, and the properties of the next PathPoint in the line are equal to each other, you create a straight-line segment. ➤ If two or more properties in a PathPoint object hold different values, the segment connected to the point is curved. To create a path or add points to an existing path using PathPoint objects, create a PathItem object, then add the path points as child objects in the PathItem: Set appRef = CreateObject ("Illustrator.Application") Set firstPath = appRef.ActiveDocument.PathItems.Add firstPath.Stroked = true Set newPoint = firstPath.PathPoints.Add 'Using identical coordinates creates a straight segment newPoint.Anchor = Array(75, 300) newPoint.LeftDirection = Array(75, 300) newPoint.RightDirection = Array(75, 300) Set newPoint2 = firstPath.PathPoints.Add newPoint2.Anchor = Array(175, 250) newPoint2.LeftDirection = Array(175, 250) newPoint2.RightDirection = Array(175, 250) Set newPoint3 = firstPath.PathPoints.Add 'Using different coordinates creates a curve newPoint3.Anchor = Array(275, 290) newPoint3.LeftDirection = Array(135, 150) newPoint3.RightDirection = Array(155, 150)