Convert dimension value to text

Discussion in 'AutoCAD' started by The Jester, Mar 22, 2007.

  1. The Jester

    The Jester Guest

    Hello,

    Does anyone of you know if there is a lisp-routine that converts the
    horizontal and vertical dimension value to text (preferably mtext).

    In other words: I want to put a text with the dimensions in a square (glass
    panel), e.g. [Horizontal value] x [Vertical value].

    Thanks very much in advance !

    Rob
     
    The Jester, Mar 22, 2007
    #1
  2. (defun c:RMSIZE (/ ha hb hc hd va vb vc vd a b th tp r )
    (setvar "OSMODE" 32)
    (setq ha (getpoint "\nPick first point horizontal dimension: "))
    (setq hc (getpoint "\nPick second horizontal point: "))
    (setq va (getpoint "\nPick first point vertical dimension: "))
    (setq vc (getpoint "\nPick second vertical point: "))
    (setq tp (getpoint "\nStart point for text: "))
    (setq th (getreal "\nEnter text height: "))
    (setq hb (car ha))
    (setq hd (car hc))
    (setq vb (cadr va))
    (setq vd (cadr vc))
    (setq a (abs (- hd hb)))
    (setq a (rtos a 4 1))
    (setq b (abs (- vd vb)))
    (setq b (rtos b 4 1))
    (setq r (strcat a " x " b))
    (setvar "OSMODE" 0)
    (graphscr)
    (command "TEXT" tp th 0 r)
    (princ)
    )
     
    Michael Bulatovich, Mar 23, 2007
    #2
  3. The Jester

    The Jester Guest

    Thank you very much, Michael !! Sorry for not thanking you sooner (all work
    and no play and such ... ;o) )

    I've tried the routine and it works great. However, since I live in Holland,
    I'd like the text in metric values, is it possible for you to edit the
    routine that way ? And if it's not too much to ask, to convert the text to
    mtext, please ? I'd be very greatful if you could.

    Another question is about the way to enter the 4 points: wouldn't it be
    simpler to select a diagonal line in a rectangle (or just the 2 points
    diagonally opposite eachother in that rectangle) and subtract the
    x-coördinates and y-coördinates from eachother ?

    Again, thanks very much for your help.

    Rob

     
    The Jester, Apr 1, 2007
    #3
  4. The 4 in (rtos a 4 1) makes it return feet and inches, and the 1 is the unit
    accuracy. If you want plain decimal numbers change the 4 to 2 wherever you
    see an (RTOS......) statement. If your units are millimeters accuracy of 1
    will be fine. If your units are meters you might want to change it to 3.
    --


    MichaelB
    www.michaelbulatovich.ca


     
    Michael Bulatovich, Apr 1, 2007
    #4
  5. You might also want to shorten the name to something more appropriate in the
    (defun....) statement, and saveas that other name dot LSP.
    --


    MichaelB
    www.michaelbulatovich.ca

     
    Michael Bulatovich, Apr 1, 2007
    #5
  6. The Jester

    The Jester Guest

    Thank you very much ! It will save me a lot of time at work, as I had to
    type in the dimensions for every glass panel in my drawings. I was used to
    'just' dimension them, but my new boss wants it as text in the panel itself.

    Much appreciated.

    Rob
     
    The Jester, Apr 1, 2007
    #6
  7. Take a penny, leave a penny.
     
    Michael Bulatovich, Apr 1, 2007
    #7
  8. The Jester

    The Jester Guest

    Yes, I know. You've explained the principle before ;o). But still ...

    Rob
     
    The Jester, Apr 1, 2007
    #8
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.