3 Replies Latest reply on Jul 25, 2011 7:12 AM by rottenuncle

    Moving a rotated rectangle [AS CS5]

    rottenuncle

      I have a script that moves items from the top half of each page to a new page, essentially like this:

       

      set mybounds to visible bounds of myitem

      tell myitem to move to myPage1

      tell myitem to move to {item 2 of mybounds, item 1 of mybounds}

      Works great except when the item is a rectangle with rotation applied. In that case, getting the bounds of the rotated item returns the bounds of the item unrotated, but when moving the item, the move to coordinates correspond to the rotated item. (or something like that, I haven't worked out exactly what is going on — rotated items get moved to the wrong spot).
      Can anyone suggest and alternative method of moving to a new page that works for rotated items?

        • 1. Re: Moving a rotated rectangle [AS CS5]
          Mac_06 Level 2

          Bit tricky but does work, Instead of moving could duplicate first item and then remove the first item.

           

          Mac

          • 2. Re: Moving a rotated rectangle [AS CS5]
            Muppet Mark Level 5

            Im having no problems with rotated objects… Moving to a new containing page will forget the visible bounds and the object will default to 0,0 but I can just re-apply the bounds back to position…

             

            tell application "Adobe InDesign CS2"

                 tell the active document

                      tell page 1

                           set ThisBox to the first rectangle

                           set BoxBounds to visible bounds of ThisBox

                      end tell

                      move ThisBox to page 2

                      set visible bounds of ThisBox to BoxBounds

                 end tell

            end tell

            • 3. Re: Moving a rotated rectangle [AS CS5]
              rottenuncle Level 1

              Tried resetting visible bounds instead of moving the rectangles. (Also tried resetting geometric bounds.) The frames moved correctly, but not the frame contents.

               

              Using duplicate instead of move worked great, though. And less code:

               

              set myNewItem to duplicate myitem to myTempPage

              delete myitem

              in place of :

              set mybounds to visible bounds of myitem

              tell myitem to move to myTempPage

              tell myitem to move to {item 2 of mybounds, item 1 of mybounds}