4 Replies Latest reply on Jun 27, 2012 1:28 PM by pkrk

    Adding text frames

    pkrk Level 1

      I'm adding text frames via a script to every layer of every spread of a file.

      The only properties I address are the geometric bounds and stroke color and size.


      On some client provided files if I run another script to tell me the geometric bounds of the textframes, on certain pages it shows the first two geometric bounds as being -.999999999999 and 0 when it is has been assigned to be -1 and 0.  But if I manually click on the text frames they are correctly showing the x y coordinates that I expect(-1,0).



      I'll try to post the code in a bit but I'm pretty sure this has more to do with the files changing from being facing pages to not and it leaving some lingering issue. Maybe I need to totally clear all facing pages properties before adding the text frames??

        • 1. Re: Adding text frames
          [Jongware] Most Valuable Participant

          InDesign is extremely accurate with its dimensions. Inside, all of your measurement units are converted to points (1/72"), with up to 12 or 13 digits of accuracy. However,


          1. Every manipulation of an object may increase or decrease the size of an object by a fractionally rounded value, due to this limited accurary of mathematic operators. Rest assured, this usually is in the range of 1E-10 points, or slightly below the wavelength of visible light. But Small Errors May Round Up. On the other hand ...


          2. I'd go barking mad if InDesign showed every single measurement in the User Interface with all of the internal digits. To preserve my sanity, ID only shows two or three most significant decimals, attuned to the scale of the current measurement unit (inches have lots of decimals, millimeters not).


          So your -.999999999999 is slightly rounded downwards, by a mere 0.000000001%, to facilitate easy reading and conserve valuable on-screen space.


          [Edit] Hah, I forgot to address that you actually input "-1" bu get something else out (*). In what unit would that be? Since ID's internal measurement unit is in points, every other unit needs to be converted into that, including some inevitable rounding.


          (*) Only by aforementioned 0.000000001%, but still, it is something else.

          • 2. Re: Adding text frames
            pkrk Level 1

            I input in inches. So I would probably best be served to figure out how many points exactly equal and inch and submit it that way...?


            I will attempt in points and report back.

            • 3. Re: Adding text frames
              [Jongware] Most Valuable Participant

              Converting the value up front is not necessary, ID does that on its own.


              Strangely enough, a conversion from inches to points *is* exact -- one inch equals 72 points. Or at least it does if you use Adobe's definition (which I think InDesign is using internally).


              I'd simply not bother about the 0.00000001% discrepancy. Even if your output is going to be scaled up, it would need to be miles (or kilometers ;) ) wide before anyone should notice it, and at such magnifications the process itself would be adding much more to any inaccuracies.


              If you want to display the value to a user, use rounding:


              valRounded = Math.round(value*1000)/1000;


              will return your value with a modest three digits of accuracy.

              • 4. Re: Adding text frames
                pkrk Level 1

                Even though I place it at -72, it still references it as -71.9999999999995...


                It must be because each page in the Indd file is a different size. Maybe somethign is "off".


                I was going to use the placement of the textframes as an identifier for another script but will have to identify those frames some other way such as the stroke color or  I could just round and be pretty sure that it is what I'm looking for. (Labels won't work for this)



                Thanks for your help. If I discover why certain pages give me the odd mth even in points I'll update the post.