5 Replies Latest reply on Feb 11, 2017 4:43 PM by moluapple

    Setting Scale Corners in a script

    DanDoodle

      I'm writing a script to fit an object into a specific sized box. I'm using:

       

      artwork[0].resize(scale, scale ,1,1,1,1,scale);

       

      in order to change the size. Everything seems to be working fine except if I have the "Scale Corners" check box in the Transform palette turned off. Then, of course, it doesn't scale the corners!

       

      I can't figure out of there is a way to either, override that in the script or change the setting and then change it back when its done.

       

      I tried:

       

      getBooleanPreference("Scale Corners");

       

      to see if I could get to it that way, but it doesn't match up with what is shown as selected!

       

      Any ideas?

        • 1. Re: Setting Scale Corners in a script
          moluapple Level 4

          Hi, to turn on the check box in script:

          app.preferences.setBooleanPreference('scaleLineWeight', 1);

          2 people found this helpful
          • 2. Re: Setting Scale Corners in a script
            DanDoodle Level 1

            Thanks @moluapple but that's not quite what I'm after. It's scale corners that I'm looking for.

             

            Here's a pic showing what's going on! When the center logo is resized, the top right logo is what happens. And the bottom right is what I want. The check box I want to switch is the one bottom left in the transform panel. (Scale Corners)

             

            resize-problem.png

             

            I've now had a quick try at "app.preferences.setBooleanPreference('scaleCorners', 1);" (thanks for the suggestion) but that still doesn't seem to do it!

            • 3. Re: Setting Scale Corners in a script
              moluapple Level 4

              Sorry, I misunderstand you before. Well, seems like we have to call an action.

              var actionStr = 
              ['/version 3',
              '/name [1 73]',
              '/actionCount 1',
              '/action-1 {',
              '    /name [ 12 7363616c65436f726e657273]',
              '    /eventCount 1',
              '    /event-1 {',
              '        /internalName (ai_liveshapes)',
              '        /parameterCount 1',
              '        /parameter-1 {',
              '            /key 1933800046',
              '            /type (boolean)',
              '            /value 1',
              '        }',
              '    }',
              '}'].join('');
              
              createAction(actionStr, 's');
              app.doScript('scaleCorners', 's');
              app.unloadAction('s','');
              
              function createAction (str, set) {
                  var f = File(set + '.aia');
                  f.open('w');
                  f.write(str);
                  f.close();
                  app.loadAction(f);
                  f.remove();
              }
              
              2 people found this helpful
              • 4. Re: Setting Scale Corners in a script
                pixxxel schubser Level 5

                Hi moluapple,

                only one note (or better addition):

                line #14 in your Code is the important line.

                     '               /value 1', // value 0 for uncheck the option Scale Corners
                

                 

                Have fun

                 

                • 5. Re: Setting Scale Corners in a script
                  moluapple Level 4

                  Of cause you are right.

                  Also note I had deleted some parts, only left the core parts of the .aia file, so now is the structure(1st line + 3 + 3 + 3 + 3 + end lines):

                  • name
                  • count
                  • action/event/parameter details