1 Reply Latest reply on Apr 4, 2014 2:14 AM by Laubender

    Group selected images

    Unique Level 1



      Help from forum.


      How do i group only the selected images.



      var g = app.activeDocument.links.itemByName("FCCP.eps" && "Spring.ai"});



      It is not working.


      Many thanks..

        • 1. Re: Group selected images
          Laubender Adobe Community Professional & MVP

          @Unique – you cannot group images, or links like you tried. Adressing two links with one itemByName() statement would not work. A closing bracket like } without an opening bracket would not make sense either. Simply wrong syntax.


          var myGraphic1 = app.documents[0].links.itemByName("FCCP.eps").parent;
          var myGraphic2 = app.documents[0].links.itemByName("Spring.ai").parent;


          With groups.add() you can specify an array of pageItems on the same spread.

          But also the following would not work and give an error:


          app.activeDocument.pages.item(0).groups.add( [ myGraphic1 , myGraphic2 ] );


          Images recide in their container frames. So, if you want to group the container frames of some images through their links, you have to adress the parent property of the links to get the placed image plus the parent of that parent to get the container frame.


          Just try this in the ESTK:








          Addressing the links by name is not a good idea.

          Names are not unique.


          Even if they would be in your case, this concept will only work in special cases. The container frames must not be nested and they have to recide on the same spread. (You cannot group objects on different spreads!).


          With groups.add() you can specify an array of pageItems on the same spread.

          And these pageItems cannot be nested.


          See the following code just to illustrate the issues.

          However I would not recommend the concept behind it:


          //A one page document with two DIFFERENT placed graphics
          //Nothing else!
          //Try with the same graphic placed TWO TIMES and the concept will fail !!
          //Otherwise it's getting complicated!!
          var myDoc = app.documents[0];
          var myName1 = myDoc.links[0].name;
          var myName2 = myDoc.links[1].name;
          var myGraphicContainer1 =  myDoc.links.itemByName(myName1).parent.parent;
          var myGraphicContainer2 =  myDoc.links.itemByName(myName2).parent.parent;