2 Replies Latest reply on Jul 5, 2012 9:27 AM by alexthebake

    Changing the Anchor Point of an Object

    alexthebake Level 1



      Let me preface this with the fact that I'm fairly new to InDesign.


      Let's say I have a rectangle on the page. The page's Anchor Point is set the the center. I'd like that to remain unchanged, however, I would like to put new geometric bounds on the rectangle with a different Anchor Point.

      How can I change the anchor point of an object using javascript?


      I thought something along the lines of:


      var item = myDoc.pageItems[0];

      item.ChangeObjectProperties.anchorPoint = AnchorPoint.BOTTOM_CENTER_ANCHOR;


      However, it says that "item" does not support the ChangeObjectProperties method.

      What can I do?

        • 1. Re: Changing the Anchor Point of an Object
          absqua Level 4

          Page items don't have anchor points; neither do pages. The layout window has a transformReferencePoint which controls the anchoring for transformations in the UI. If you're assigning a new geometricBounds to a page item, you're essentially defining the coordinates of all four points of the bounding box, so anchoring doesn't really come into it. If you want to, say, double the height of a box but leave its bottom where it is, you can use the resize() method:


          item.resize(CoordinateSpaces.INNER_COORDINATES, AnchorPoint.BOTTOM_CENTER_ANCHOR, ResizeMethods.MULTIPLYING_CURRENT_DIMENSIONS_BY, [ResizeConstraints.KEEP_CURRENT_VALUE, 2]);


          Transformations in InDesign are hard, though; I certainly don't fully understand them. It's usually easier to just do all the arithmetic you need to to come up with a new geometricBounds for the page item.



          • 2. Re: Changing the Anchor Point of an Object
            alexthebake Level 1

            Thanks so much! Yea, I guess that was the method I was looking for