Jun 13, 2009

Selected Status of Anchor Points

With Illustrator's scripting function, you can examine the selected state of any anchor point (PathPoint), and let a script affect only for anchors which are in particular state.

The available values are:
  • ANCHORPOINT
  • LEFTDIRECTION
  • LEFTRIGHTPOINT
  • NOSELECTION
  • RIGHTDIRECTION
With the following script, you can check the state that each anchor point is in.
// shows selected state of each anchor of the selected path
var pi = activeDocument.selection[0];
var p = pi.pathPoints;

for(var i = 0; i < p.length; i++){
alert( p[i].selected );
}
The following another simple script selects every other anchor of the selected pathes.
(Grouped pathes and compound pathes are ignored.)
// selects every other anchor of the selected pathes.
var sel = activeDocument.selection;

var p, i;
for(var j = 0; j < sel.length; j++){
sel[j].selected = false;
p = sel[j].pathPoints;

for(var i = 0; i < p.length; i++){
if( i % 2 == 1 )
p[i].selected = PathPointSelection.ANCHORPOINT;
}
}
After running this script, you can apply the effect of tools only to the selected anchors.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.