how to know then length of a text.

Discussion in 'AutoCAD' started by youngman, Jan 19, 2004.

  1. youngman

    youngman Guest

    hi

    as you know we can know the heiht ot a text ,I wonder how to get the length
    of a text,

    thanks
     
    youngman, Jan 19, 2004
    #1
  2. youngman

    Michel Guest

    Hi,
    You can get the length of a text-object by getting the boundingbox of a textobject. This function returns the lower left corner and the upper right corner of the text-object. A little calculation will get you the length of the text-object. BTW, be careful with text-rotation!

    objText.GetBoundingBox varMin, varMax


    Michel
     
    Michel, Jan 19, 2004
    #2
  3. youngman

    youngman Guest

    thanks,
    i understand.
    regards
    ------------------------
    textobject. This function returns the lower left corner and the upper right
    corner of the text-object. A little calculation will get you the length of
    the text-object. BTW, be careful with text-rotation!
     
    youngman, Jan 20, 2004
    #3
  4. youngman

    youngman Guest

    but if the text is rotated, GetBoundingBox will not give us the length of
    it.

    is that so.

    thank you
     
    youngman, Jan 21, 2004
    #4
  5. but if the text is rotated, GetBoundingBox will not give us the length of
    You are correct, but you can calculate the length if you know the bounding
    box and the text angle, I think. I attached a bitmap that shows the formula
    to find the text length (shown as the bold line in the sketch). The
    calculation is for text rotation angles less than 90 degrees. For angles
    from 90 deg to 360 deg, the formula may change a little, but would be very
    similar. The variables in the sketch are:

    Ltext = the text length you are looking for
    Htext = the text height
    theta = the text rotation angle
    Lbb = the x-direction length of the bounding box

    Hope this is useful to you. I don't have time to check my math, so there
    is no warranty with this sketch.

    James
     
    James Belshan, Jan 21, 2004
    #5
  6. That is correct. Here is one solution:

    1) Store the rotation of the text in a variable.
    2) Change the rotation of the text to zero.
    3) Get the bounding box of the text.
    4) Restore the text's original rotation from the variable.
     
    Chuck Gabriel, Jan 21, 2004
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.