• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

From drawing to code...

Community Beginner ,
Jul 11, 2024 Jul 11, 2024

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

TOPICS
Scripting

Views

71

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 11, 2024 Jul 11, 2024

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

Votes

Translate

Translate
Adobe
Community Expert ,
Jul 11, 2024 Jul 11, 2024

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines