5 Replies Latest reply on Jun 11, 2013 4:47 AM by DriveFST

    selecting ConstrainProportions for scaling

    DriveFST

      Hi forum,

       

      Is it possible to select the Constrain proportions for scaling link button in Control panel, using script.

      trns.png

       

      Could forum help on this request.

       

      regrds,

      @ chand.

        • 2. Re: selecting ConstrainProportions for scaling
          DriveFST Level 1

          thanks Vam!

           

          I can find lot of stuffs there, but when i tried to search for the above options, i couldn't find it.

           

          I just want to click the scaling proportionally options in the control panel menu through script,
          instead of using this..app.selection[0].fit(FitOptions.FILL_PROPORTIONALLY);

           

          so, this is what i m trying is...

           

          app.selection[0].horizontalScale = width of the page - both margins;

          (not mentioning the vertical scale percentage here, bcause, Im trying to click the Constrain proportionally when scale option in control panel)

           

          thanks in advance VAM.

           

          I'm sorry if i m confusing...

          • 3. Re: selecting ConstrainProportions for scaling
            Jump_Over Level 5

            Hi,

             

            As far as I know you can't switch this option by JS (no such application preference to use)

             

            But Vam showed you the way how to reach your goal just with THIS method "resize()"

             

            Sample:

            mObj = app.selection[0];
            tarWidth = widthOfThePage - bothMargins;     // variables to set
            mObj.resize(
                CoordinateSpaces.INNER_COORDINATES,
                AnchorPoint.TOP_LEFT_ANCHOR,     // another?
                ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,
                [tarWidth, ResizeConstraints.KEEP_CURRENT_PROPORTIONS]
                )
            

             

            Jarek

            PS: Vam showed this way to me as well, to tell you the true

            1 person found this helpful
            • 4. Re: selecting ConstrainProportions for scaling
              Vamitul Level 4

              I see....

              well.. first of all, you can't manipulate the interface from scripting, with the exception of "clicking" a menu.

              second, it's usually a bad idea to try to emulate using scripting the exact things you do manually form the interface. You miss out on most of the power of scripting, and using things like: app.select(), app.copy etc comes with a large performance penalty.

              using scripting you can access an object (or even a lot of objects) directly, without needing to select it before, and you can manipulate them in any way you want.

              for your example, using a fixed width of 120mm:

              app.selection[0].resize(CoordinateSpaces.INNER_COORDINATES,AnchorPoint.TOP_CENTER_ANCHOR,ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,[(new UnitValue('120mm')).as('pt'),ResizeConstraints.KEEP_CURRENT_PROPORTIONS])
              

              also, remember that a page does not have a "width" property (weird, i know), it has a bounds property in the format [y1, x1, y2, x2]. so:

              width=myPage.bounds[3]-myPage.bounds[1]
              

               

              for the margins you can use http://jongware.mit.edu/idcs5/pc_MarginPreference.html

               

               

              I know for now it looks daunting, but keep with it, and as you start to get more familiar with the DOM and JavaScript in general it will start to make more sense, and you will discover how easy and incredibly powerful scripting can be.

               

               

              Best of luck,

              Vlad

              • 5. Re: selecting ConstrainProportions for scaling
                DriveFST Level 1

                Ideas & ideas,

                 

                Genius & Genius,

                 

                Hi Jump_over & Vamitul..

                 

                Ofcouse, vam it looks difficult to understand at this starting point,  by now and till, I try to learn the ideas of scripting.

                 

                thanks for the great idea to both of you.G.