4 Replies Latest reply on Jan 6, 2011 7:08 AM by Harbs.

    Converting Between Measurement Units

    mlavie Level 1

      If I want to convert inches to points, etc., do I have to manually do the conversion, or does InDesign scripting have some ready method (or at least constants) to do the work for me?


      I am essentially interested in converting all possible MesurementUnits to and from points, as point in the basic unit which InDesign uses internally.




        • 1. Re: Converting Between Measurement Units
          Kasyan Servetsky Level 5

          Use Unit Value:

          var myUV = new UnitValue("72 pt");
          if (myUV.type == "?")
              $.writeln("Unknown unit type entered.");
              // Get the value in a particular measurement unit
              $.writeln("Inches: " + myUV.as("in"));
              $.writeln("Inches: " + myUV.as("inch"));
              $.writeln("Millimeters: " + myUV.as("mm"));
              $.writeln("Points: " + myUV.as("pt"));
              $.writeln("Picas: " + myUV.as("pica"));
              $.writeln("Ciceros: " + myUV.as("cicero"));
              // Convert the UnitValue object to a specific measurement unit
              // Show before conversion unit value output:
              $.writeln("Before conversion: " + myUV);
               // Convert the UnitValue into inches
              // Show after conversion unit value output
              $.writeln("After conversion: " + myUV);
          1 person found this helpful
          • 2. Re: Converting Between Measurement Units
            [Jongware]-9BC6tI Level 4

            This older post -- http://forums.adobe.com/message/3343724 -- shows how it should work, but as Marc points out you have to be careful when doing math.


            Personally, I use the following exact definitions:


            1 in = 72 pt

            1 in = 25.4 mm

            1 mm = 0.1 cm


            -- I'd have to look up the correct value for agates (which nobody uses anyway, so I really don't bother -- tee hee).


            By the way, the definition of inches-to-mm is scientifically exact (the inch is defined in terms of millimeters, and the millimeter is defined in terms of some twenty zillion waves of a certain light from a certain crystal), but there always has been some confusion about the point. A better conversion value would be 1 pt = 1/72.27 in, but just because it was easier to calculate with, Adobe "re-defined" their points to 1/72th exactly (no doubt that was way before floating point calculations were taken for granted). InDesign still has a relic setting because of this: in Preferences, Units & Increments, you can still choose between "Postscript Units" and "Traditional", as well as yet two other (slightly) different values.

            • 3. Re: Converting Between Measurement Units
              mlavie Level 1

              Sorry - I should have been more specific. I am using ActionScript, which does not have the UnitValue class.


              What are the possible solutions for ActionScript?




              • 4. Re: Converting Between Measurement Units
                Harbs. Level 6

                If you don't have the ActionScript 3 Cookbook, get it!


                There's a lot of useful utility classes included with the book. One of them is a Unit class which provides methods for all kinds of conversions. I haven't checked if they have ones like points, picas and agates, etc. but basic ones like inches and millimeters are definitely in there...


                It's not hard to write your own conversions though...