I have a lispoutine that adds up nummers.
When I select a text it copies and ads 1 to it.
So when I select a 2 it copies and places a 3.
(defun c:add ( / OBJECT)
(setq OBJECT (ssget))
(setq pt (cdr (assoc 10 (entget (ssname OBJECT 0)))))
(command "copy" OBJECT "" pt pt)
(command "move" OBJECT "" pt pause)
(setq cnt 0)
(repeat (sslength OBJECT)
(setq txt (cdr (assoc 1 (entget (ssname OBJECT cnt))))) (setq txt (itoa (1+ (atoi txt)))) ; converts string into integer (setq ent (subst (cons 1 txt) (assoc 1 (entget (ssname OBJECT cnt))) (entget (ssname OBJECT cnt)))) (entmod ent) (setq cnt (1+ cnt)) )
)
This works fine.
Only I want to place a text in front of it. Like
"part 1" copies into "part 2"
"Atoi" turns a text into an integer.
How can I split the selected text (like part 1) into
"part " (=string) --> setq PART <string>
"1" (=integer) --> setq integer txt
add 1 to the integer
To combine I know you have to use:
(setq PARTTOTAL (strcat PART TXT))
But I'm stuck further.
can anybody help me?
thanks
Laura
When I select a text it copies and ads 1 to it.
So when I select a 2 it copies and places a 3.
(defun c:add ( / OBJECT)
(setq OBJECT (ssget))
(setq pt (cdr (assoc 10 (entget (ssname OBJECT 0)))))
(command "copy" OBJECT "" pt pt)
(command "move" OBJECT "" pt pause)
(setq cnt 0)
(repeat (sslength OBJECT)
(setq txt (cdr (assoc 1 (entget (ssname OBJECT cnt))))) (setq txt (itoa (1+ (atoi txt)))) ; converts string into integer (setq ent (subst (cons 1 txt) (assoc 1 (entget (ssname OBJECT cnt))) (entget (ssname OBJECT cnt)))) (entmod ent) (setq cnt (1+ cnt)) )
)
This works fine.
Only I want to place a text in front of it. Like
"part 1" copies into "part 2"
"Atoi" turns a text into an integer.
How can I split the selected text (like part 1) into
"part " (=string) --> setq PART <string>
"1" (=integer) --> setq integer txt
add 1 to the integer
To combine I know you have to use:
(setq PARTTOTAL (strcat PART TXT))
But I'm stuck further.
can anybody help me?
thanks
Laura