Quantcast
Channel: Adobe Community : Discussion List - Illustrator Scripting
Viewing all articles
Browse latest Browse all 3671

Recheck pathItems.length property in for loop

$
0
0

hello everyone,

 

i need your help , i am grouping pathitems and text frames in a layer , while looping through pathitems and text frames using for loop  , if required pathitem and text frames is found it will group move the group to beginning , but here is the problem so pathitem position is changed so i could miss many pathitems so how to resolve this problem.

 

for eg

 

here is my code

 

function read_create()

{

  

  for(layer_iteration=0;layer_iteration<layer_file.length;layer_iteration++)

    {

 

 

if (layer_file[layer_iteration].locked){

 

 

       layer_file[layer_iteration].locked=false;

       }

 

 

    if(layer_file[layer_iteration].name=="NUMBER")

    {

        var theGrp =layer_file[layer_iteration].pathItems;

      

 

 

          for(var i=0,len1=theGrp.length; i<len1; i++) {

             

      

 

 

if(theGrp[i].pathPoints.length == 8)

              if(theGrp[i].stroked == true && theGrp[i].filled == true) {

           var strkColor = new CMYKColor();

 

 

        strkColor.cyan = Math.round(theGrp[i].strokeColor.cyan);

        strkColor.magenta = Math.round(theGrp[i].strokeColor.magenta);

        strkColor.yellow = Math.round(theGrp[i].strokeColor.yellow);

        strkColor.black = Math.round(theGrp[i].strokeColor.black);

     

        if(Math.round(theGrp[i].strokeWidth*25.4/72*10)/10 == 0.3 && strkColor.cyan == magentaColor.cyan && strkColor.magenta == magentaColor.magenta && strkColor.yellow == magentaColor.yellow && strkColor.black == magentaColor.black) { 

            

            

 

 

 

 

                 x=Math.round(theGrp[i].pathPoints[1].anchor[0]);

                 y=Math.round(theGrp[i].pathPoints[3].anchor[1]);

                 xx=Math.round(theGrp[i].pathPoints[5].anchor[0]);

                 xy=Math.round(theGrp[i].pathPoints[7].anchor[1]);

                 count=0;

                  for(text_iteration=0,len=layer_file[layer_iteration].textFrames.length;text_iteration<len ;text_iteration++)

                 {

                     if(text_frame[text_iteration].contents.match(/[A-Z]{1}[0-9]{1}$/) != null||text_frame[text_iteration].contents.match(/[A-Z]{1}[0-9]{2}$/) != null||text_frame[text_iteration].contents.match(/[A-Z]{1}[0-9]{3}$/) != null){

                        

                   t=Math.round(text_frame[text_iteration].anchor[1]);

                

                   t1=(Math.round(text_frame[text_iteration].anchor[0]))

                   alert(text_frame[text_iteration].contents);

                 

                 if(t1>xx&&t1<x){

                     if(t>y&&t<xy) {

                       

                    

                    

                  {

                    

                      var newGroup = layer_file[layer_iteration].groupItems.add();

                      newGroup.name = text_frame[text_iteration].contents+":";

                      theGrp[i].moveToBeginning(newGroup);

                      text_frame[text_iteration].moveToBeginning(newGroup);

                      len=layer_file[layer_iteration].textFrames.length;

                 

                      

                      }

                 

               }}}

 

 

   }}}}}}}}}


Viewing all articles
Browse latest Browse all 3671

Trending Articles



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