4 Replies Latest reply on Feb 28, 2014 4:00 AM by WhiteMAX

    reset graphics shape to rectangle

    WhiteMAX

      Hello,

      i have little problem.

       

      What i'm doing wrong? ;-)

       

      tell application "Adobe InDesign CC"

                tell active document

                          repeat with thisGraphic in all graphics of every page

                                    set shape of thisGraphic to rectangle

                          end repeat

                end tell

      end tell

        • 1. Re: reset graphics shape to rectangle
          Mary Posner Level 3

          I'd suggest targeting the frames you want to reshape, not the graphics. Start by getting a reference to every frame that contains an image.

           

          You'll want to look at the dictionary for the correct syntax for changing the shape. If you were to make this change to the frame manually, you'd find it under Object > Convert Shape. Search in the dictionary for "convert shape" and you'll find the required wording.

           

          Also, please note that there's a dedicated InDesign Scripting forum. You'll find many knowledgeable and helpful scripters there. Happy scripting!

          • 2. Re: reset graphics shape to rectangle
            rob day Adobe Community Professional & MVP

            What i'm doing wrong? ;-)

            You do have to work on the frame (the parent of the graphic) and not the graphic. You can reset the bounds like this:

             

            tell application "Adobe InDesign CS6"

             

                repeat with x in all graphics of active document

                    set p to parent of x

                    set {a, b, c, d} to geometric bounds of p

             

                    set myPath to path 1 of item 1 of p

             

                    if (count of path points of myPath) is 4 then

                         --start from the upper left corner  b,a and go around clockwise to lower left d,a

                        set anchor of path point 1 of myPath to {b, a}

                        set anchor of path point 2 of myPath to {b, c}

                        set anchor of path point 3 of myPath to {d, c}

                        set anchor of path point 4 of myPath to {d, a}   

                    end if   

                end repeat

            end tell

            • 3. Re: reset graphics shape to rectangle
              rob day Adobe Community Professional & MVP

              Or as Mary suggests you can use the simpler convert to shape, which will also turn triangles and other shapes into rectangles. The bounds method might be better if you are trying to repair rectangles that you accidentally have turned into polygons.

               

              tell application "Adobe InDesign CS6"

                  repeat with x in all graphics of active document

                      tell parent of x

                          convert shape given convert to rectangle

                      end tell

                  end repeat

              end tell

              • 4. Re: reset graphics shape to rectangle
                WhiteMAX Level 1

                @Rob Day,

                thanks, the last one is short and working