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

Resize top level groups

$
0
0

Running a for loop on all groups in a document. If group parent is a layer and layer is free then clipping mask and resize. Resize function fails as "Error 21 undefined is not an object" on the THIRD group in this example.

Test_001.eps - Google Drive

 

#target Illustrator

 

var idoc = app.activeDocument;

var gi = idoc.groupItems;

 

function meetTheParents(PageItem){

     if (PageItem.parent.typename = "Layer"){

          return "Layer";

     }

}

 

function isLayerFree(layer){

     if (layer.locked == false && layer.visible == true){

          var gpa = layer.parent;

          isLayerFree(gpa);

          return true

          } else {

     return false

     }

}

 

 

for (j = gi.length -1; j >= 0; j--) {

     var iGroup = gi[j];

     if (iGroup.hidden==false && iGroup.locked==false) {

          if (meetTheParents(iGroup) == "Layer"){

               if (isLayerFree(iGroup.parent)){

                    iGroup.selected = true;

                    app.executeMenuCommand ('makeMask');

                    app.executeMenuCommand ('deselectall');

                    iGroup.resize(50,50,true,true,true,true,50,Transformation=Transformation.CENTER);

                    // alert(iGroup.typename);

               }

          }

     }

}

It fails AFTER it does the clipping mask so the for loop is functioning properly. It resizes properly the first TWO times so the resize function is written correctly. If I comment out the resize command and uncomment the alert of iGroup's type name it completes successfully so the identity of the group in question is not an issue.

 

?!?!?!?!?!?


Viewing all articles
Browse latest Browse all 12845

Trending Articles



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