5 Replies Latest reply on Nov 17, 2010 12:07 PM by Harbs.

    [AS] How to create an anchored rectangle in CS3 ?

    zeRafio Level 1

      Hi all,

       

      I'm unable to create an anchored rectangle in CS3 using AppleScript.

       

      I tried this:

      tell insertion point 1 of text frame 1

      make rectangle with properties {stroke weight:0, geometric bounds:{0, 0, 20, 20}}

      end tell

       

      Any help?

        • 1. Re: [AS] How to create an anchored rectangle in CS3 ?
          L. Guy O'Rojo Level 2

          I don't know if that's possible. What I do (in a find/replace script) is copy the graphic, select the text that the graphic will replace, and then paste the graphic. That replaces the text with the graphic.

          • 2. Re: [AS] How to create an anchored rectangle in CS3 ?
            zeRafio Level 1

            Thank you for your help.

             

            I've finally found how to do this:

             

            set insertPoint to insertion point 1 of selection

            tell insertPoint

            set myBox to make rectangle

            end

             

            No other syntax is working.

             

             

            • 3. Re: [AS] How to create an anchored rectangle in CS3 ?
              Olav Martin Kvern Level 3

              Hi zeRafio,

               

              I think the problem with your original version was that setting the bounds of the rectangle was failing. After you create a rectangle in an insertion point, you'll need to recompose the story before you set the bounds. This works:

               

              tell application "Adobe InDesign CS3"
                   set myDocument to make document
                   tell view preferences of myDocument
                        set vertical measurement units to points
                        set horizontal measurement units to points
                   end tell
                   tell page 1 of myDocument
                        set myTextFrame to make text frame with properties {geometric bounds:{72, 72, 144, 144}}
                   end tell
                   tell insertion point 1 of myTextFrame
                        set myRectangle to make rectangle
                   end tell
                   --Recompose the story before setting the bounds of the rectangle.
                   tell parent story of myTextFrame to recompose
              end tell

               

              Thanks,

               

              Ole

              • 4. Re: [AS] How to create an anchored rectangle in CS3 ?
                Harbs. Level 6

                Ole,

                 

                IIRC, Recompose is not necessary in CS3. I think CS2 was the last version that it was necessary.

                 

                It IS necessary to set the geometric bounds after it is created though...

                 

                I REALLY wish we had a width and height property for page items which we could set irrelvent to whether they actually appear on a page...

                 

                Harbs

                • 5. Re: [AS] How to create an anchored rectangle in CS3 ?
                  Olav Martin Kvern Level 3

                  Hi Harbs,

                   

                  As far as I can tell, recompose is still necessary. It's true that you'll usually get good bounds from the rectangle after creating it, but I want to stress the word "usually." I've seen bad bounds in some cases in CS5, so I'm not ready to declare that we can omit the recompose just yet.

                   

                  Thanks,

                   

                  Ole