7 Replies Latest reply on Jan 7, 2015 8:53 AM by TᴀW

    How to create an anchored group?

    TᴀW Adobe Community Professional & MVP

      I can make an anchored text frame:

       

      myAnchoredFrame = myInsertionPoint.textFrames.add();

       

      I can create a group on a page:

       

      myPage.groups.add();

       

      But I cannot create an anchored group!

       

      myAnchoredGroup = myInsertionPoint.groups.add();

       

      Result: "myInsertionPoint.groups.add() is not a function".

       

      I've had to resort to app.cut() and app.paste().

       

      But I'd like to know how to do this properly next time.

       

      If anyone knows how to do this, it would be much appreciated.

       

       

       

        • 1. Re: How to create an anchored group?
          Laubender Adobe Community Professional & MVP

          @Ariel –try the following:

           

          1. We need an insertion point

          2. We need a group (not anchored)

          Both on the same spread!

           

          Then do the following:

           

          myGroup.anchoredObjectSettings.insertAnchoredObject(myInsertionPoint);
          

           

          Afterwards you could change all the anchored object settings of the group to your will.

           

          Uwe

          • 2. Re: Re: How to create an anchored group?
            Laubender Adobe Community Professional & MVP

            The method insertAnchoredObject() and its counterpart releaseAnchoredObject() was introduced with InDesign CS5.5.

             

            For insertAnchoredObject() there is a second, optional argument: anchoredPosition, that can be defined as:

             

            AnchorPosition.INLINE_POSITION

            AnchorPosition.ABOVE_LINE

            AnchorPosition.ANCHORED

             

            So the code could be expanded to e.g.:

             

            myGroup.anchoredObjectSettings.insertAnchoredObject(myInsertionPoint,AnchorPosition.INLINE_POSITION);
            

             

            Uwe

            • 3. Re: Re: How to create an anchored group?
              Laubender Adobe Community Professional & MVP

              Oops. I was wrong with method releaseAnchoredObject().

              That was already introduced with InDesign CS4.

              (Just looked up the documentation)

               

              Uwe

              • 4. Re: How to create an anchored group?
                Laubender Adobe Community Professional & MVP

                Also just tested as I was wrong on a second assumption:

                The insertion point and the group not necessarly should be on the same spread.

                 

                Sorry for the confusion…

                 

                Uwe

                • 5. Re: How to create an anchored group?
                  TᴀW Adobe Community Professional & MVP

                  Thanks Uwe -- that's the method I was looking for. Didn't know it existed!

                   

                  So I wonder how this would be done in CS4. Surely there must be a way to create an anchored group in CS4 without resorting to cut and paste!

                  • 6. Re: Re: How to create an anchored group?
                    Laubender Adobe Community Professional & MVP

                    Hm … I don't think so.

                    In CS4 you have to use a combination of app.cut() and app.paste().

                     

                    Ok. What we can do, or what might be the next best thing is not grouping objects, but nesting objects inside a rectangle, that can be added to an insertion point. It's not a group, but something similar.

                     

                    //An InsertionPoint is selected
                    //its parentTextFrame should be at least sized 110 x 110 (whatever measurement units are there)
                    var myInsertionPoint = app.selection[0]; //An insertio
                    var myAnchoredRectangle = myInsertionPoint.rectangles.add({geometricBounds:[0,0,100,100]});
                    var myGBs = myAnchoredRectangle.geometricBounds;
                    
                    //Add a new rectangle to the anchored rectangle:
                    myAnchoredRectangle.rectangles.add({geometricBounds:[myGBs[0],myGBs[1],myGBs[2]-50,myGBs[3]-50], fillColor : "Yellow"});
                    //Add a second rectangle to the anchored rectangle:
                    myAnchoredRectangle.rectangles.add({geometricBounds:[myGBs[0]+50,myGBs[1]+50,myGBs[2],myGBs[3]], fillColor : "Magenta"});
                    

                     

                    Uwe

                    • 7. Re: How to create an anchored group?
                      TᴀW Adobe Community Professional & MVP

                      That's pretty weird!

                       

                      Thanks Uwe.

                       

                      Ariel