PDA

View Full Version : Change existing text to a number, then increment other text objects by specified...



timothyjturner
2005-10-10, 05:31 PM
I am attempting to write a lisp that will allow me to edit many different lines of text mathematically... I want to be able to select a user's selection(s) and allow them to enter a value such as 1234LS... change the selected text to this value... then ask for an increment value, user enters value (example 10)...then they select next text and it changes to 1244LS, then next selection to 1254LS and so on until user makes no selection.... any advice? I think I could figure this out if I could figure out how to edit both single lines of text and mtext.

Thanks!

Wanderer
2005-10-10, 05:33 PM
test (will edit if this works)Appears it works, look forward to your question, and just for future tinkering, don't forget that the New Users Forum (http://forums.augi.com/forumdisplay.php?f=47)is a place to test out posting, formatting, etc. :)

Mike.Perry
2005-10-10, 09:24 PM
Hi

Check out the following Submission # EX001352 by Peter Jamtgaard on the AUGI Exchange Page -

AUGI Exchange Search Page (http://www.augi.com/exchange/search.asp?page=415)

Have a good one, Mike

ccowgill
2005-10-10, 10:14 PM
Express tools has a similar tool, it is called tcount, it takes a number and will increment it in many ways, try checking it out.

timothyjturner
2005-10-11, 05:28 PM
I ended up solving my problem thanks to the file reference that Mike included. This helped me figure out how to write selection sets and such a little faster... Thanks Mike!

An interesting thing, I don't know if anybody knows this or not. I discovered by accident that the atoi command automatically truncates any characters that are not 0-9 if they come after 0-9 characters... so (atoi "1234LS") returns 1234 as an integer. Very nice.

Here is the code that I used to accomplish what I needed. Feel free to use or modify as you wish. :)

By Tim Turner (10/05)
(defun C:inc ()
(setq init_str (getstring "\n Enter Initial Value:"))
(setq inc (getint "\n Enter Increment:"))
(setq init_val (atoi init_str))
(setq init_val_str (itoa init_val))
(setq suffix (vl-string-trim init_val_str init_str))
(setq ss (ssget))
(setq ent (entget (ssname ss 0)))
(setq ent (subst (cons 1 init_str) (assoc 1 ent) ent))
(entmod ent)
(while 1
(setq ss (ssget))
(setq init_val (+ init_val inc))
(setq inc_val (itoa init_val))
(setq ent (entget (ssname ss 0)))
(setq
ent (subst (cons 1 (strcat inc_val suffix)) (assoc 1 ent) ent)
)
(entmod ent)
)
)

rxk
2016-08-11, 11:35 PM
Hi Tim,

How about if I want increment as a suffix.. example S2001, S2002, S2003 etc.

Sorry I am familiar with lisp programming.

Thank you.