10 Replies Latest reply on Mar 9, 2012 8:36 AM by HectorresDesign

    How do I scale square frames in CS5 using applescript?

    HectorresDesign Level 1

      I need help fixing a script which changes the scale of square frames after it duplicates them. The script worked fine in CS1 but not for CS5. I tried changing "resize" to "scale" but it doesn't compile correctly. Does anyone know how to change "resize mySelection01 horizontal scale 21.6 vertical scale 21.6" to work for CS5?

      Thanks,

      Hector

       

       

      tell application "Adobe InDesign CS5.5"

          set myDocument to active document

          tell myDocument

              set startinglayer to "Image"

              tell page 2 of myDocument

                  set mySelection01 to rectangle 1

                  duplicate mySelection01

                  resize mySelection01 horizontal scale 21.6 vertical scale 21.6

                  move mySelection01 to page 28 of myDocument

                  move mySelection01 to {15, 55}

                  set properties of mySelection01 to {fill color:swatch "None" of myDocument, stroke color:swatch "Black" of myDocument, stroke type:stroke style "Solid" of myDocument, stroke weight:0.25}

                 

              end tell

              tell page 4 of myDocument

                  set mySelection02 to rectangle 1

                  duplicate mySelection02

                  resize mySelection02 horizontal scale 21.6 vertical scale 21.6

                  move mySelection02 to page 28 of myDocument

                  move mySelection02 to {116, 55}

                  set properties of mySelection02 to {fill color:swatch "None" of myDocument, stroke color:swatch "Black" of myDocument, stroke type:stroke style "Solid" of myDocument, stroke weight:0.25}

                 

              end tell

              tell page 6 of myDocument

                  set mySelection03 to rectangle 1

                  duplicate mySelection03

                  resize mySelection03 horizontal scale 21.6 vertical scale 21.6

                  move mySelection03 to page 28 of myDocument

                  move mySelection03 to {218, 55}

                  set properties of mySelection03 to {fill color:swatch "None" of myDocument, stroke color:swatch "Black" of myDocument, stroke type:stroke style "Solid" of myDocument, stroke weight:0.25}

                 

              end tell

              tell page 8 of myDocument

                  set mySelection04 to rectangle 1

                  duplicate mySelection04

                  resize mySelection04 horizontal scale 21.6 vertical scale 21.6

                  move mySelection04 to page 28 of myDocument

                  move mySelection04 to {319, 55}

                  set properties of mySelection04 to {fill color:swatch "None" of myDocument, stroke color:swatch "Black" of myDocument, stroke type:stroke style "Solid" of myDocument, stroke weight:0.25}

                 

              end tell

              tell page 10 of myDocument

                  set mySelection05 to rectangle 1

                  duplicate mySelection05

                  resize mySelection05 horizontal scale 21.6 vertical scale 21.6

                  move mySelection05 to page 28 of myDocument

                  move mySelection05 to {15, 157}

                  set properties of mySelection05 to {fill color:swatch "None" of myDocument, stroke color:swatch "Black" of myDocument, stroke type:stroke style "Solid" of myDocument, stroke weight:0.25}

                 

              end tell

              tell page 12 of myDocument

                  set mySelection06 to rectangle 1

                  duplicate mySelection06

                  resize mySelection06 horizontal scale 21.6 vertical scale 21.6

                  move mySelection06 to page 28 of myDocument

                  move mySelection06 to {116, 157}

                  set properties of mySelection06 to {fill color:swatch "None" of myDocument, stroke color:swatch "Black" of myDocument, stroke type:stroke style "Solid" of myDocument, stroke weight:0.25}

                 

              end tell

              tell page 14 of myDocument

                  set mySelection07 to rectangle 1

                  duplicate mySelection07

                  resize mySelection07 horizontal scale 21.6 vertical scale 21.6

                  move mySelection07 to page 28 of myDocument

                  move mySelection07 to {218, 157}

                  set properties of mySelection07 to {fill color:swatch "None" of myDocument, stroke color:swatch "Black" of myDocument, stroke type:stroke style "Solid" of myDocument, stroke weight:0.25}

                 

              end tell

              tell page 16 of myDocument

                  set mySelection08 to rectangle 1

                  duplicate mySelection08

                  resize mySelection08 horizontal scale 21.6 vertical scale 21.6

                  move mySelection08 to page 28 of myDocument

                  move mySelection08 to {319, 157}

                  set properties of mySelection08 to {fill color:swatch "None" of myDocument, stroke color:swatch "Black" of myDocument, stroke type:stroke style "Solid" of myDocument, stroke weight:0.25}

                 

              end tell

              tell page 18 of myDocument

                  set mySelection09 to rectangle 1

                  duplicate mySelection09

                  resize mySelection09 horizontal scale 21.6 vertical scale 21.6

                  move mySelection09 to page 28 of myDocument

                  move mySelection09 to {15, 258}

                  set properties of mySelection09 to {fill color:swatch "None" of myDocument, stroke color:swatch "Black" of myDocument, stroke type:stroke style "Solid" of myDocument, stroke weight:0.25}

                 

              end tell

              tell page 20 of myDocument

                  set mySelection10 to rectangle 1

                  duplicate mySelection10

                  resize mySelection10 horizontal scale 21.6 vertical scale 21.6

                  move mySelection10 to page 28 of myDocument

                  move mySelection10 to {116, 258}

                  set properties of mySelection10 to {fill color:swatch "None" of myDocument, stroke color:swatch "Black" of myDocument, stroke type:stroke style "Solid" of myDocument, stroke weight:0.25}

                 

              end tell

              tell page 22 of myDocument

                  set mySelection11 to rectangle 1

                  duplicate mySelection11

                  resize mySelection11 horizontal scale 21.6 vertical scale 21.6

                  move mySelection11 to page 28 of myDocument

                  move mySelection11 to {218, 258}

                  set properties of mySelection11 to {fill color:swatch "None" of myDocument, stroke color:swatch "Black" of myDocument, stroke type:stroke style "Solid" of myDocument, stroke weight:0.25}

                 

              end tell

              tell page 24 of myDocument

                  set mySelection12 to rectangle 1

                  duplicate mySelection12

                  resize mySelection12 horizontal scale 21.6 vertical scale 21.6

                  move mySelection12 to page 28 of myDocument

                  move mySelection12 to {319, 258}

                  set properties of mySelection12 to {fill color:swatch "None" of myDocument, stroke color:swatch "Black" of myDocument, stroke type:stroke style "Solid" of myDocument, stroke weight:0.25}

                 

              end tell

          end tell

      end tell

        • 1. Re: How do I scale square frames in CS5 using applescript?
          Muppet Mark Level 5

          Hector… I will take a look at the new syntax for resizing in CS5… While I do, consider using a loop for operations like this… There is no need to repeat syntax like you have done… Have the syntax repeat itself… You probably only need some variables for positions x, y and an incrementor…

           

          tell application "Adobe InDesign CS5"

                    tell the active document

                              repeat with i from 2 to 24 by 2

                                        tell page i

            -- do stuff here

                                        end tell

            display alert i giving up after 1

                              end repeat

                    end tell

          end tell


          • 2. Re: How do I scale square frames in CS5 using applescript?
            HectorresDesign Level 1

            Thanks for the tip, the script would be a lot simpler with a single repeating line. I'll try to implement the change you suggested and thanks for looking into the syntax.

             

            Hector

            • 3. Re: How do I scale square frames in CS5 using applescript?
              Kevin Parrott Level 2

              hI Hector

               

              using geometric bounds will set your rectangle size

               

               

              tell application "Adobe InDesign CS5.5"

                  set myDocument to active document

                  tell myDocument

                      set startinglayer to "Image"

                      tell page 2 of myDocument

                          set mySelection01 to rectangle 1

                          duplicate mySelection01

                          set geometric bounds of mySelection01 to {0, 0, 21.6, 21.6} 

                          move mySelection01 to page 28 of myDocument

                          move mySelection01 to {15, 55}

                          set properties of mySelection01 to {fill color:swatch "None" of myDocument, stroke color:swatch "Black" of myDocument, stroke type:stroke style "Solid" of myDocument, stroke weight:0.25}

                      end tell

                  end tell

              end tell

              • 4. Re: How do I scale square frames in CS5 using applescript?
                HectorresDesign Level 1

                I'm going to try your script now and see if it works, thank you!

                • 5. Re: How do I scale square frames in CS5 using applescript?
                  HectorresDesign Level 1

                  Hi Kevin,

                   

                  I just ran the script and its making the correct size frame which is great. The only thing missing is the images are not being scaled with the frame and are left at their original size. Do you know what code I can add to make the images scale along with the frame?

                   

                  Thank you so much,

                  Hector

                  • 6. Re: How do I scale square frames in CS5 using applescript?
                    Kevin Parrott Level 2

                    my appologies, please try this

                     

                    tell application "Adobe InDesign CS5.5"

                        set myDocument to active document

                        tell myDocument

                            set startinglayer to "Image"

                            tell page 2 of myDocument

                                set mySelection01 to rectangle 1

                                duplicate mySelection01

                                set properties of item 1 of mySelection01 to {horizontal scale:21.6, vertical scale:21.6}

                                --set geometric bounds of mySelection01 to {0, 0, 21.6, 21.6}

                                fit rectangle 1 given center content

                                move mySelection01 to page 28 of myDocument

                                move mySelection01 to {15, 55}

                                set properties of mySelection01 to {fill color:swatch "None" of myDocument, stroke color:swatch "Black" of myDocument, stroke type:stroke style "Solid" of myDocument, stroke weight:0.25}

                            end tell

                        end tell

                    end tell

                    • 7. Re: How do I scale square frames in CS5 using applescript?
                      HectorresDesign Level 1

                      you rock! that code worked. I just added this line to my code "set properties of item 1 of mySelection01 to {horizontal scale:21.6, vertical scale:21.6}" and it worked. Now if I could make a loop instead of repeating the code like Mark said the scripts would be perfect. But I'm extremely happy this works, saves so much time

                       

                      Thank you,

                      Hector

                      • 8. Re: How do I scale square frames in CS5 using applescript?
                        Kevin Parrott Level 2

                        great, glad that worked,  i agree with mark, it will shorten your code (less code is good), and

                        maybe speed up the operation

                         

                        kp

                        • 9. Re: How do I scale square frames in CS5 using applescript?
                          Muppet Mark Level 5

                          Hector, I would have gone the route of transforming the rectangle myself… but matrix is a little tricky to get the lingo right… Only done it in ExtendScript before now… Any how this should give you the general idea of the loop… Your X&Y values are not equidistant so I went for a list instead…

                           

                          tell application "Adobe InDesign CS5"

                                    tell the active document

                                              set dupPage to page 28

                            -- Loop the 12 items

                                              repeat with i from 1 to 12

                            -- A list of 12 X&Y pair lists

                                                        set posBox to {{15, 55}, {116, 55}, {218, 55}, {319, 55}, ¬

                                                                  {15, 157}, {116, 157}, {218, 157}, {319, 157}, ¬

                                                                  {15, 258}, {116, 258}, {218, 258}, {319, 258}}

                            -- Double the value of i for the page ref

                                                        tell page (i * 2)

                                                                  set dupeBox to duplicate rectangle 1

                            -- Transform the matrix here

                                                                  -- or use your property value change…

                            move dupeBox to dupPage

                            move dupeBox to item i of posBox

                                                                  set fill color of dupeBox to "None"

                                                                  set stroke color of dupeBox to "Black"

                                                                  set stroke type of dupeBox to "Solid"

                                                                  set stroke weight of dupeBox to 0.25

                                                        end tell

                                              end repeat

                                    end tell

                          end tell

                          1 person found this helpful
                          • 10. Re: How do I scale square frames in CS5 using applescript?
                            HectorresDesign Level 1

                            Mark, your code works perfectly. I used your code and added the scale line.The code now works and is a lot simpler:

                             

                            tell application "Adobe InDesign CS5.5"

                             

                                tell the active document

                             

                                    set dupPage to page 28

                             

                                    -- Loop the 12 items

                             

                                    repeat with i from 1 to 12

                             

                                        -- A list of 12 X&Y pair lists

                             

                                        set posBox to {{14.4, 57.875}, {134.875, 57.875}, {255.875, 57.875}, {375.875, 57.875}, ¬

                                            {14.4, 177.875}, {134.875, 177.875}, {255.875, 177.875}, {375.875, 177.875}, ¬

                                            {14.4, 297.875}, {134.875, 297.875}, {255.875, 297.875}, {375.875, 297.875}}

                             

                                        -- Double the value of i for the page ref

                             

                                        tell page (i * 2)

                             

                                            set dupeBox to duplicate rectangle 1

                             

                                            -- Transform the matrix here

                                            set properties of item 1 of dupeBox to {horizontal scale:21.6, vertical scale:21.6}

                                            -- or use your property value change…

                             

                                            move dupeBox to dupPage

                             

                                            move dupeBox to item i of posBox

                             

                                            set fill color of dupeBox to "None"

                             

                                            set stroke color of dupeBox to "Black"

                             

                                            set stroke type of dupeBox to "Solid"

                             

                                            set stroke weight of dupeBox to 0.25

                             

                                        end tell

                             

                                    end repeat

                             

                                end tell

                             

                            end tell