I'm needing some sort of script that will put ( ) around numbers. I don't think I have any over 99, so if it worked with 2 digits it would save me a ton of time.
Example:So I've got an existing number of 25 and I need it to read (25).
Thanks!!!
I'm needing some sort of script that will put ( ) around numbers. I don't think I have any over 99, so if it worked with 2 digits it would save me a ton of time.
Example:So I've got an existing number of 25 and I need it to read (25).
Thanks!!!
The only difference between me and a madman is that I'm not mad.
SALVADOR DALI
Do you want something like this one?
or:Code:(setq num 25) (setq res (vl-princ-to-string (read (strcat "(" (itoa num) ")"))))
~'J'~Code:(setq num "25") (setq res (strcat "(" num ")"))
"The whole problem with the world is that fools and fanatics are always
so certain of themselves, and wiser people so full of doubts."
Bertrand Russell
If I understand the code correctly, neither...???
Let me expand it a little more: I've got text numbered 1 through 99 through out the drawing, multiple times. Now I need to change 1 to 99 to (1) to (99). So, I guess I gave a bad example, 25 was just a number, but I've got numbers from 1 all the way to 99. I even have 23-1, 23-2, 23-3 numbers or even 23-1A in a few places. But to keep the code simple, I'd be happy with .lsp program that does 10 to 99.
The only difference between me and a madman is that I'm not mad.
SALVADOR DALI
Here is an old one you can change to suit you needs.
Code:(defun c:PAR(/ tset1 tlng1 to1 to2 tx1 tx2 ntx to3) ; Adds parenthes to ending and beginning (command "_.undo" "_end") (command "_.undo" "_group") (prompt "\nSelect text to put parenthesis around: ") (setq tset1 (ssget '((0 . "*TEXT")))) (if (= tset1 nil) (setq tlng1 0) (setq tlng1 (sslength tset1)) ) (while (/= tlng1 0) (setq to1 (ssname tset1 0)) (setq to2 (entget to1)) (setq tx1 (assoc 1 to2)) (setq tx2 (cdr tx1)) (setq ntx (strcat "(" tx2 ")")) (setq to3 (subst (cons 1 ntx) tx1 to2)) (entmod to3) (entupd to1) (ssdel to1 tset1) (setq tlng1 (1- tlng1)) ) (command "_.undo" "_end") (princ) )
I got an error loading it.
; error: bad argument type: numberp: nil
The only difference between me and a madman is that I'm not mad.
SALVADOR DALI
Can you post what the command lines says when you run the code. Are you able to select objects? I just tried it, and it worked when I selected something and when I didn't, so I'm not sure why it errored one you.
Well, maybe I should start off by saying after 20 years in AutoCAD, I still don't really do .lsp. I know just enough to hack someone elses code, but to start new, I just can't do it. Html code, I'm not bad at that.
Anyway, this is the error I get:
Command: (LOAD "PAR")
; error: bad argument type: numberp: nil
Oh, also running AutoCAD MAP 2007 on this computer.
The only difference between me and a madman is that I'm not mad.
SALVADOR DALI
You can just copy/paste the code to the command line, and the just type 'par' at the command line to run it. If you want to put it in a file, then you need to copy/paste it to a file, and save the file with a .lsp extension, and then load the file. If the file is in the search path, then you can just type '(load "filename.lsp")' if it's not then you need to type in the whole path.
Hope the helps.