6 Replies Latest reply on Sep 27, 2011 9:08 AM by Neonphotos

    write "inch" in scripts

    NEON LAI

      Hi

       

      The following is the script i wrote. I want to change the "point" {200,300} to "inch" {4.5i,5i} in demension.

      After i change it , i cannot run the script. Does anybody know how to input "inch" instead of "point".

      Many thanks, Neon

       

       

       

      tell application "Adobe InDesign CS5"

        tell pages of active document

        resize item 1 in inner coordinates from center anchor by replacing current dimensions with values {200, 300}

        end tell

      end tell

        • 1. Re: write "inch" in scripts
          csm_phil Level 4

          Hi Neon,

           

          Try the below code in InDesign Scripting Guide provided.

           

          tell application "Adobe InDesign CS5"

          set myDocument to active document

          tell view preferences of myDocument

          set myOldXUnits to horizontal measurement units

          set myOldYUnits to vertical measurement units

          set horizontal measurement units to points

          set vertical measurement units to points

          end tell

          --At this point, you can perform any series of script actions that depend on

          --the measurement units you’ve set. At the end of the script, reset

          --the measurement units to their original state.

          tell view preferences of myDocument

          set horizontal measurement units to myOldXUnits

          set vertical measurement units to myOldYUnits

          end tell

          end tell

           

           

          And also you can try this.

           

           

          tell application "Adobe InDesign CS5"
            tell pages of active document
            resize item 1 in inner coordinates from center anchor by replacing current dimensions with values {"4.5 in", "5 in"}
            end tell
          end tell
          

           

           

          Thx

          csm_phil

          • 2. Re: write "inch" in scripts
            NEON LAI Level 1

            Hi Phil, thanks for your advice. However, i got the message as attached when i input "inch" as the way advised.

            Neon

            图片 1.png

            • 3. Re: write "inch" in scripts
              csm_phil Level 4

              Hi Neon,

               

              Try this below AS code.

               

              tell application "Adobe InDesign CS5"

                  set myDocument to active document

                  tell view preferences of myDocument

                      set horizontal measurement units to inches

                      set vertical measurement units to inches

                     

                      tell pages of myDocument

                          resize item 1 in inner coordinates from center anchor by replacing current dimensions with values {200, 300}

                      end tell

                     

                  end tell

              end tell

               

              thx

              csm_phil

              • 4. Re: write "inch" in scripts
                NEON LAI Level 1

                Hi Phil,

                 

                Thanks and tried your AS code. However, the result is same. I can still change the document size.

                But  i cannot change the input values from points {200, 300} to inches {"4.5 in", "5 in"}.

                • 5. Re: write "inch" in scripts
                  Marc Autret Level 4

                  Hi,

                   

                  resize, resolve, and similar PageItem methods expect dimensions or locations in points—unless the reference point is specified relative to a page with consideringRulerUnits set to true.

                  Hence I suggest you use the UnitValue helper to convert inches into points.

                   

                  @+

                  Marc

                  • 6. Re: write "inch" in scripts
                    Neonphotos

                    Hi Marc,

                     

                    Thanks for your advice. However, i am new in scripting and it seems a little complicated to me. Would you show me the complete scripts

                    then i just paste it onto script editor for the trial, many thanks

                     

                    Neon