7 Replies Latest reply on May 28, 2008 11:28 AM by (Dave_Saunders)

    Moving anchored item to specific location

      Hi

      How to move the anchored rectangle object to any specific location around

      Regards
      Suresh
        • 1. Re: Moving anchored item to specific location
          Level 1
          Assuming the target location is legal (on the same spread and within any constraints set up in the anchored object options), just use the move method. Changing the geometric bounds doesn't work.

          Dave
          • 2. Re: Moving anchored item to specific location
            Level 1
            var aa=myFoundItems[k].paragraphs
            var myAnchorFrame=aa.item(0).insertionPoints.item(0)
            Hi Dave

            var myLibraryItem=app.libraries[i].assets[j]; myFrm=myLibraryItem.placeAsset(myAnchorFrame);

            myFrm[0].move[myBounds[1],myBounds[0]+54]

            Here i am placing the library rectangle object into my position and trying to move some 54pt from the top.(Y1 position).

            But this is executing but the rectangle is not moving from the actual anchored position.

            Regards
            Suresh

            Pls. help me out.
            • 3. Re: Moving anchored item to specific location
              Level 1
              The syntax of the move command doesn't look right. It should be:

              myFrm[0].move([myBounds[1],myBounds[0]+54]);

              Dave
              • 4. Re: Moving anchored item to specific location
                Level 1
                Hi Suresh,

                Even if you get the syntax of the move method right (thanks, Dave!), it won't work to move an anchored item. Instead, use the options in the anchored object settings to change the position of the frame relative to its anchor point.

                Thanks,

                Ole
                • 5. Re: Moving anchored item to specific location
                  Level 1
                  Ole,

                  Changing the geometric bounds of anchored objects doesn't work, but move does -- at least, relative moves do (not that this was one). Here's a function I used in a recent successful script (that addressed anchored objects colliding with each other):
                  function firstPass(anchs, page) {
                  
                    // works forwards through anchored objects looking for overlaps
                    // if any are found, shuffles downwards
                    // anchs is known to be of length 2 or more
                    for (j = 0; anchs.length - 1 > j; j++) {
                      if (PIsOverlap(anchs[j], anchs[j+1], page)) {
                        var topGBs = anchs[j].geometricBounds;
                        var botGBs = anchs[j+1].geometricBounds;
                        anchs[j+1].move(undefined,
                        [0, topGBs[2] + 0.0972 - botGBs[0]]);
                      }
                    }
                    return PIsOverlap(anchs[anchs.length -2],anchs[anchs.length - 1],page);
                  }
                  Perhaps I started with absolute moves and discovered they didn't work -- I can't remember.

                  Dave
                  • 6. Re: Moving anchored item to specific location
                    Level 1
                    Hi Dave,

                    What I'm saying, however, is that what happens with move, relative or absolute, depends on the anchored object settings. In most cases, either nothing will happen or the object will move in an unexpected way. The anchored object settings are the right place to control the position of anchored objects--what's wrong with using them?

                    Thanks,

                    Ole
                    • 7. Re: Moving anchored item to specific location
                      Level 1
                      Not a lot, except it can mean yet another set of calculations to work out what the equivalent change is.

                      Dave