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

Selecting a Single Anchor Point at the Start of a Script

Engaged ,
Sep 12, 2018 Sep 12, 2018

Copy link to clipboard

Copied

Sorry to ask but is there a way to automatically select an Anchor Point?  It will always be the Lowest point (and because there will be multiple on that Y-axis) I want the Left most point.

Capture3.PNG

Thank you!

TOPICS
Scripting

Views

636

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

Valorous Hero , Sep 12, 2018 Sep 12, 2018

Hello, check this out.

Make sure your art item is wholly selected in the document first - that's how it knows to affect only the points in a group or compound path that is desired among all which could be present in the document at any time.

The underlying assumption is that you may have a line of points at the bottom and at the top - whereby the tolerance is a buffer area which would include the range of points along which some of the x axis would be included - because you will have situations wh

...

Votes

Translate

Translate
Adobe
Valorous Hero ,
Sep 12, 2018 Sep 12, 2018

Copy link to clipboard

Copied

Hello, check this out.

Make sure your art item is wholly selected in the document first - that's how it knows to affect only the points in a group or compound path that is desired among all which could be present in the document at any time.

The underlying assumption is that you may have a line of points at the bottom and at the top - whereby the tolerance is a buffer area which would include the range of points along which some of the x axis would be included - because you will have situations where the bottom most point isn't a leftmost point, etc.

#target illustrator

function test(){

  var tolerance = 10;

  var doc = app.activeDocument;

  var selectedItem = doc.selection[0];

  var bottomMost, thisPoint, thisPathItem;

  var allContainedPoints = [];

  for (var i = 0; i < doc.pathItems.length; i++) {

    thisPathItem = doc.pathItems;

    if(!thisPathItem.selected){

      continue;

    }

    for (var j = 0; j < doc.pathItems.pathPoints.length; j++) {

      thisPoint = doc.pathItems.pathPoints;

      allContainedPoints.push(thisPoint);

    }

  }

  allContainedPoints.sort(function(a,b){

    return a.anchor[1] < b.anchor[1];

  });

  for (var i = 0; i < allContainedPoints.length; i++) {

    thisPoint = allContainedPoints;

    if(i == 0){

      bottomMost = thisPoint.anchor[1];

    } else {

      if(thisPoint.anchor[1] < bottomMost){

        bottomMost = thisPoint.anchor[1];

      }

    }

  }

  doc.selection = null;

  var bottomMostItems = [];

  for (var i = 0; i < allContainedPoints.length; i++) {

    thisPoint = allContainedPoints;

    // $.writeln(thisPoint.anchor[1] + " : " + bottomMost);

    if(thisPoint.anchor[1] + tolerance >= bottomMost && thisPoint.anchor[1] - tolerance <= bottomMost){

      bottomMostItems.push(thisPoint);

    }

  }

  bottomMostItems.sort(function(a,b){

    return a.anchor[0] > b.anchor[0];

  });

  bottomMostItems[0].selected = PathPointSelection.ANCHORPOINT;

};

test();

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
Explorer ,
Sep 13, 2018 Sep 13, 2018

Copy link to clipboard

Copied

LATEST

I want to divide the text quickly by the space character.

Enthusiastic friends, I have a problem, can you help me write this? Thank you very much.

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