Copy link to clipboard
Copied
I know how to write the code (*.jsx) that will draw a path in Illustrator. By path I mean a number of path points (anchor point, pair of direction points, ...).
BUT is there a way to ‘get’ the location of .Anchor, .LeftDirection, .RightDirection. from a selected path? So, from drawing to code...
Hi @Paul3398437880ag, sure... have a look at this:
(function () {
var doc = app.activeDocument;
var pathItem = doc.selection[0];
if ('PathItem' !== pathItem.constructor.name)
return alert('Please select a path item and try again.');
for (var i = 0, p; i < pathItem.pathPoints.length; i++) {
p = pathItem.pathPoints[i];
alert(
'PathPoint ' + i
+ '\nanchor: ' + p.anchor
+ '\nleftDirection: ' + p.leftDirection
...
Copy link to clipboard
Copied
Hi @Paul3398437880ag, sure... have a look at this:
(function () {
var doc = app.activeDocument;
var pathItem = doc.selection[0];
if ('PathItem' !== pathItem.constructor.name)
return alert('Please select a path item and try again.');
for (var i = 0, p; i < pathItem.pathPoints.length; i++) {
p = pathItem.pathPoints[i];
alert(
'PathPoint ' + i
+ '\nanchor: ' + p.anchor
+ '\nleftDirection: ' + p.leftDirection
+ '\nrightDirection: ' + p.rightDirection
);
}
})();
You can directly set those properties too, eg.
p.anchor = [10,20];
See PathPoint docs.
- Mark