Jump to content

adding a comma to numbers in autocad


Recommended Posts

newchurchr

Does anyone know the fastest way to add commas to numbers in autocad? I have alot of numbers in a drawing and i need to add commas to them all. Is there a lisp i could use to add them all at once?

Link to post
Share on other sites
newchurchr

i saved the text as an .lsp and loaded thru appload just like i always have and then i type rtoc to active the command nothing happens is there something i'm doing wrong.

 

(defun rtoc ( n p / d i l x )
   (setq d (getvar 'dimzin))
   (setvar 'dimzin 0)
   (setq l (vl-string->list (rtos n 2 p))
         x (cond ((cdr (member 46 (reverse l)))) ((reverse l)))
         i 0
   )
   (setvar 'dimzin d)
   (vl-list->string
       (append
           (reverse
               (apply 'append
                   (mapcar
                      '(lambda ( a b )
                           (if (and (zerop (rem (setq i (1+ i)) 3)) b)
                               (list a 44)
                               (list a)
                           )
                       )
                       x (append (cdr x) '(nil))
                   )
               )
           )
           (member 46 l)
       )
   )
)

Edited by rkmcswain
Added CODE tags
Link to post
Share on other sites

You have to call it and pass two variables the number and precison (rtoc 123456789.09876 2)

 

(defun rtoc ( n p / d i l x ) defun rtoc, n & P are two variables to be supplied, d i l x are local variables used in the code, the / seperates local and global variables.

 

 

(setq num 1234567.23)
(rtoc num 2)

Link to post
Share on other sites
rkmcswain
i saved the text as an .lsp and loaded thru appload just like i always have and then i type rtoc to active the command nothing happens is there something i'm doing wrong.

 

I'm not sure what else I can show you. Pass this function a real number (the one you want to add commas to), and an integer (the level of precision you want).

 

It's not a full working command that will allow you to select entities, etc.

 

Command: (rtoc 123456789.09876 2)
"123,456,789.10"

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...