0 Replies Latest reply on May 18, 2015 10:50 AM by S Hopkins

    AppleScript Corner Options

    S Hopkins Adobe Community Professional

      If you try to create a page item with rounded corner options (or any corner option), you will find there is a nasty bug with AppleScript. The compiler just will not let you set the corner option for the bottom right corner. There was an answer to this problem posted a few years back that used the raw (chevron) code to work around the bug. (See Mar 27, 2011 Applescript:Corner Options Am I mad or did I find a bug?)

      My solution has been to create a default object style with rounded corners and then apply the object style whenever I needed rounded corners. I then override the corners that are not to be rounded, and set radius as needed.

      Recently, however, I was putting a sample script together that would create a button that had just the top left and bottom right corners rounded. I found that the raw (chevron) code for bottom right corner option no longer worked (OS 10.9.5, InDesign CC 2014.1). You might want to try the following yourself:

      tell application "Adobe InDesign CC 2014"

        set docRef to the active document

        tell docRef

        set rectRef to make rectangle with properties {geometric bounds:{50, 50, 150, 150}, fill color:"Black"}

        tell rectRef

        set the top left corner option to rounded corner

        set the top left corner radius to 12

        set the top right corner option to none

        set the bottom left corner option to none

        set the «property pcO4» to rounded corner --that is a capital O, not a zero

        set the bottom right corner radius to 12

        end tell

        end tell

      end tell

       

      The compiler changes the line to (notice double space after "bottom"):

           set the bottom  right corner to rounded corner

      and posts the following error:

           A property can't go after this property

       

      To try to solve the problem, I removed the raw code from within the tell statement to InDesign.The script then begins with

      set theProperty to «property pcO4»

      tell application "Adobe InDesign CC 2014"

      --then later, in the tell rectRef block

      set theProperty to rounded corner

      The code compiles, changing «property pcO4» to «class pcO4» and the corner does not round.

       

      Of course, if all corners are to be rounded, you can create the rectangle and then convert it to a rounded rectangle shape:

      tell application "Adobe InDesign CC 2014"

        set docRef to the active document

        tell docRef

        set rectRef to make rectangle with properties {geometric bounds:{50, 50, 150, 150}, fill color:"Black", theProperty:rounded corner}

        tell rectRef

        convert shape given convert to rounded rectangle corner radius 12

        end tell

        end tell

      end tell