Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all articles
Browse latest Browse all 12845

How to select the outermost pathPoints in Compound or Grouped pathItems?

$
0
0

Hello Hiroyuki, Carlos and AISComm.,

 

i have an number of paths in a group each filled with single colors.

3) I hoped there is a way to select the outermost pathPoints on the perimeter of the group?

 

The following script i just found by wysiwygbill at: http://forums.adobe.com/message/3046178#3046178  ..,he writes: "..it's supposed to return the outermost bounds of the group". So it may save time in adapting it to select the points at the outermost bounds.

Please let me know if this is helpful and can be done?

 

Thanks as always, for your valued help and effective coding,

Jeff

 

 

function getRealVisibleBounds(grp) {

     var outerBounds = [];

     for(var i = grp.pageItems.length - 1; i >= 0;i--)  {

          var bounds = [];

          if(grp.pageItems[i].typename == 'GroupItem') {

               bounds =  getRealVisibleBounds(grp.pageItems[i]);

          }

          else if((grp.pageItems[i].typename == 'PathItem' || grp.pageItems[i].typename == 'CompoundPathItem')

               && (grp.pageItems[i].clipping || !grp.clipped)) {

               bounds = grp.pageItems[i].visibleBounds;

          }

          if (bounds.length > 0) {

               outerBounds = maxBounds(outerBounds,bounds);

          }

     }

     return (outerBounds.length == 0) ? null : outerBounds;

}

 

function maxBounds(ary1,ary2) {

     var res = [];

     if(ary1.length == 0)

          res = ary2;

     else if(ary2.length == 0)

          res = ary1;

     else {

          res[0] = Math.min(ary1[0],ary2[0]);

          res[1] = Math.max(ary1[1],ary2[1]);

          res[2] = Math.max(ary1[2],ary2[2]);

          res[3] = Math.min(ary1[3],ary2[3]);

     }

     return res;

}

 

function positionVisible(grp,x,y)

{

     var bounds = getRealVisibleBounds(grp);

     var newX = x + (grp.left - bounds[0]);

     var newY = y + (grp.top - bounds[1]);

     grp.position = [newX,newY];

}


Viewing all articles
Browse latest Browse all 12845


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>