4 Replies Latest reply on Aug 31, 2010 3:00 AM by mikeybabes68

    Unused Rectangle frame removal

    mikeybabes68

      Hi scripters

       

      I am using data merge to generate some menu tables via simple csv import, however i generate about 300pages worth.

       

      The template uses a mixture of a graphic file or plain text as inported data.

      however when i have completed i need to remove all unused frames from all the pages. the reason is i have some frames and text next to eachother as part of the design when not used i would hand select all them with the visual cross as seen visuall and just delete.

       

      i am unable to find how i can check all frames which have no files associated to them and just do a bulk delete.

       

      I expect the answer is less words this the message.

       

      I new to scripting, and trying to use reference is a task in itself.

       

      Any pointers is much appreciated.

       

      It's a shame data merge does only just the basic part, the tidy up process just takes as long.

       

      thanks for reading.

        • 1. Re: Unused Rectangle frame removal
          brettpolo Level 1

          Assuming that the graphic frames are all rectangles:

           

          rects = app.activeDocument.rectangles;
          
          for (i = rects.length; i--;){
               if (rects[i].graphics.length == 0){
                    rects[i].remove();
               }
          }
          
          • 2. Re: Unused Rectangle frame removal
            mikeybabes68 Level 1

            Hi,

             

            This indeed works perfectly.

             

            However I have emedded the rectangles inside a text frame, as i used tabs on some fields.

             

            I am unsure why the rectangles object is not removed when this is case.

             

            I select one rectangle item and on JAVAScript Console execute app.selection[0]

            it correctly returns as Result: [object Rectangle]

             

            it would be nice if there was a more detailed method to return full information.

             

            I guess there is some differences in details when part of an embedded.rectangle my knowledge at the moment is unable to find this.

             

            Thanks for your time.

            • 3. Re: Unused Rectangle frame removal
              Shonkyin Level 3

              Use this code for removing box within stories.

               

              var myDoc = app.activeDocument;
              var myStories = myDoc.stories;
              for (var a= 0; a<myStories.length; a++)
              {
                   var myPictureBox = myStories[a].rectangles;
                   for (p = myPictureBox.length-1; p>=0; p--)
                   {
                        if (myPictureBox[p].graphics.length == 0)
                        {
                             myPictureBox[p].remove();
                        }
                   }
              }
              

               

               

              Shonky

              • 4. Re: Unused Rectangle frame removal
                mikeybabes68 Level 1

                Hi,

                 

                This works perfect.

                 

                I will learn from your information. I hope other people can also find it helpful.

                 

                Thanks to this forum for such expert advise.

                 

                WBR