2 Replies Latest reply on Oct 18, 2012 4:06 PM by Trevorׅ

    grouping all items

    watonnozelisdahier Level 1

      Hi,

       

      does someone know how to group all items with label matching ("EMS_pos").

      I would like to give this group an new label 'EMScode" and to rotate ?

       

       

      please help

       

       

      newgroup = []; for (i=0; i<oPageItems.length; i++)

      if (oPageItems[i].label.match("EMS_pos")) 

      newgroup.push(oPageItems[i]);

      app.activeDocument.groups.add(newgroup);

      newGroup.label="EMScode";

      newGroup.rotationAngle = 45;

        • 1. Re: grouping all items
          Trevorׅ Adobe Community Professional

          This is VERY HEAVILY based on Marc Aurett's script from here http://forums.adobe.com/message/4624711#4624711

          See the link for how it works and extras.

           

          var LABEL_PREFIX = "EMS_pos";
          
          var doc = app.documents.length && app.activeDocument,
              spreads = doc && doc.spreads,
              s = spreads ? spreads.length : 0,
              items, a=[], t, i, z=0, newGroup;
          
          while( s-- )
              {
              items = spreads[s].pageItems.everyItem().getElements();
              i = items.length;
              z = 0;
              while( i-- )
                  {
                  if( 0 != (t=items[i]).label.indexOf(LABEL_PREFIX) ) continue;
                  a[z++] = t;
                  }
              z && newGroup = spreads[s].groups.add(a);
              a.length = 0;
              }
          newGroup.rotationAngle = 45;
          

           

          Trevor

          • 2. Re: grouping all items
            Trevorׅ Adobe Community Professional

            This is corrected

            My (not Marc's) Mistake in the above script

             

            //http://forums.adobe.com/thread/1084493?tstart=0
            #target indesign
            app.doScript("main()", ScriptLanguage.javascript, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "Make Index");function main()
            {
            var  LABEL_PREFIX = "EMS_pos",
                    doc = app.documents.length && app.activeDocument,
                    spreads = doc && doc.spreads,
                    s = spreads ? spreads.length : 0,
                    items, a=[], t, i, z=0, newGroup;
            
            while( s-- )
                {
                items = spreads[s].pageItems.everyItem().getElements();
                i = items.length;
                z = 0;
                while( i-- )
                    {
                    if ((t=items[i]).label != (LABEL_PREFIX) ) continue;
                    a[z++] = t;
                    }
               newGroup = z && spreads[s].groups.add(a);
               newGroup.rotationAngle = 45;
               a.length = 0;
                }
            }
            
            1 person found this helpful