Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

positioning objects with applescript

Contributor ,
Oct 20, 2014 Oct 20, 2014

Hi all, i'm an applescript noob and i began to learn its basics to automate some tricky tasks of my daily work.

I wrote a very simple code - and it actually works - , but i need to refine it.

Here it is:

tell application "Adobe InDesign CC 2014"

    tell active document

        tell every master spread

            tell every page to make rectangle with properties {stroke weight:0, absolute horizontal scale:1, absolute vertical scale:1, fill color:"Paper", transparency settings:{blending settings:{opacity:0.1}}}

        end tell

    end tell

end tell

This script automatically places my rectangle somewhere on the top left corner - why? - of every page; i tried it on another mac but it doesn't work as well, because the rectangle appears outside the page.

So, is there a way to tell my rectangle to, for example, snap to the top margin of every page, in the middle? This way there shouldn't be problems anymore...

Hope to find a way, thanks all.

Alessandro

TOPICS
Scripting
2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 28, 2014 Oct 28, 2014

You position a rectangle via geometric bounds:

tell application "Adobe InDesign CS6"   

    tell active document

        --get the view prefs and set units to inches and the origin to page

        set viewprefs to properties of view preferences

        set properties of view preferences to {horizontal measurement units:inches, vertical measurement units:inches, ruler origin:page origin}

       

        --the bounds of the rectangle in y1,x1,y2,x2 format

        --y1 and x1 are the x,y coordinates of t

...
Translate
Community Expert ,
Oct 28, 2014 Oct 28, 2014

You position a rectangle via geometric bounds:

tell application "Adobe InDesign CS6"   

    tell active document

        --get the view prefs and set units to inches and the origin to page

        set viewprefs to properties of view preferences

        set properties of view preferences to {horizontal measurement units:inches, vertical measurement units:inches, ruler origin:page origin}

       

        --the bounds of the rectangle in y1,x1,y2,x2 format

        --y1 and x1 are the x,y coordinates of the upper left corner relative to the ruler settings

        --y2 and x2 are the bottom right corner

        --so this makes a 3" square

        set mybounds to {1.0, 2.0, 4.0, 5.0}

        tell every master spread

            tell every page to make rectangle with properties {geometric bounds:mybounds, stroke weight:0, fill color:"Black"}

        end tell

       

          --reset rulers

        set properties of view preferences to viewprefs

    end tell

end tell

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 28, 2014 Oct 28, 2014

Thanks a lot, I'll try it asap, it seems it could work

Since you're the only one who answered, is there a way to run the script as a "single" action? I mean, with a click I can run several automatic actions, but when I cmd+z it undoes actions one by one: it would be great if I could undo the entire script with a single cmd+z...

Thanks again, bye!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 28, 2014 Oct 28, 2014
LATEST

I don't think so. You could run a save at the beginning of a script and then there would be the option to revert.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines