Rounding a text string

Discussion in 'AutoCAD' started by ffejgreb, Jan 21, 2004.

  1. ffejgreb

    ffejgreb Guest

    I've asked this in the past and reviewed several other posts concerning
    this, but I just can't figure out how to make it work. I've written a
    routine that is to select a polygon, capture it's area, then create a string
    of text using that area. Here is what I have:

    (defun c:sft (/ b1 p1 h1)
    (setq b1 (entsel))
    (command ".area" "e" b1)
    (setq b1 (getvar "area"))
    (setq p1 (getpoint "\nPick start point for CENTER Justified text: "))
    (setq h1 (getdist "\nText height: "))
    (command ".text" "j" "c" p1 h1 "0" b1)
    (princ)
    )

    The problem is that the value of b1 has 12 places to the right of the
    decimal and I would like it to have only two. Can someone please help me
    correct this?

    Thank again for your help,

    Jeff
     
    ffejgreb, Jan 21, 2004
    #1
  2. ffejgreb

    L. White Guest

    Try: (setq b1 (rtos b1 2 2))
    hth
     
    L. White, Jan 21, 2004
    #2
  3. ffejgreb

    ffejgreb Guest

    That worked. Thanks a bunch. I'm still very new to programming in lisp and
    had seen other responses where rtos and atof were used in and it wasn't
    working for me. I'll keep plugging away.
     
    ffejgreb, Jan 21, 2004
    #3
  4. ffejgreb

    ffejgreb Guest

    I hate it when spell checker removes a word. That should say "rtos and atof
    were used in conjunction..."
     
    ffejgreb, Jan 21, 2004
    #4
  5. ffejgreb

    Adesu Guest

    HI ffejgreb,where you find e and what "e" ?

    Command: area
    Specify first corner point or [Object/Add/Subtract]: e
     
    Adesu, Oct 22, 2004
    #5
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.