cestel Posted June 16, 2011 Share Posted June 16, 2011 Hello, I am a newbie to lisp and have a question for all you exprerienced lisp coders. I have a block for elevations, which have to attributes (for concrete and finish elevation). I want to add a specific number to this attributes. The format is "+7.05" or "-7.00", i found some lisps but they all change the format(if the sum is an integer) to "7" or "-7". Does any one used a script adding/subtructing a specific number without deleting the numbers after coma and plus sign? we do not have to select a specific attribute, i can copy to a new file and add/subtract from all att. in that file. i found an older script which is written by ASMI; http://www.cadtutor.net/forum/showthread.php?21726-Numerical-Global-Block-Attribute& and a simple one (defun AddNumAtt (add tag / e ei et txt) (setq e (entnext) tag (strcase tag)) (while (setq e (entnext e)) (setq ei (entget e) et (cdr (assoc 0 ei))) (and (= "ATTRIB" et) (wcmatch (cdr (assoc 2 ei)) tag) (setq txt (cdr (assoc 1 ei))) (numberp (setq num (read txt))) (entmod (subst (cons 1 (rtos (+ add num) 2 2)) (assoc 1 ei) ei)) ; ) 2 2) change second 2 for precision. (entupd e))) (princ)) ;(AddNumAtt 10 "*") ; (AddNumatt value to +/- tagname) Thanks for your help. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted June 16, 2011 Share Posted June 16, 2011 I want to add a specific number to this attributes. The format is "+7.05" or "-7.00", i found some lisps but they all change the format(if the sum is an integer) to "7" or "-7". Without seeing the offending code... The RTOS function *should* be able to fix that. :wink: Quote Link to comment Share on other sites More sharing options...
cestel Posted June 16, 2011 Author Share Posted June 16, 2011 Actually, i really dont know where to add the RTOS functon Quote Link to comment Share on other sites More sharing options...
ReMark Posted June 16, 2011 Share Posted June 16, 2011 Your profile says you are using AutoCAD LT. Is that correct? Quote Link to comment Share on other sites More sharing options...
cestel Posted June 16, 2011 Author Share Posted June 16, 2011 Usually i use LT, but i have a shared license, so now i use Autocad 2011. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted June 16, 2011 Share Posted June 16, 2011 Actually, i really dont know where to add the RTOS functon No worries, we'll try to help. Is the LISP code above the code you're wanting to use? If not, please post the desired code so we can take a look. Quote Link to comment Share on other sites More sharing options...
cestel Posted June 16, 2011 Author Share Posted June 16, 2011 Hello again, With some help i've find the solution with RTOS. but it adds a + sign before - so user have to find and replace the "+-" to"-". and precision should be 0.00. Thanks a lot. (defun AddNumAtt (add tag / e ei et txt) ` (setq e (entnext) tag (strcase tag)) (while (setq e (entnext e)) (setq ei (entget e) et (cdr (assoc 0 ei))) (and (= "ATTRIB" et) (wcmatch (cdr (assoc 2 ei)) tag) (setq txt (cdr (assoc 1 ei))) (numberp (setq num (read txt))) (entmod (subst (cons 1 (strcat "+" (rtos (+ add num) 2 2))) (assoc 1 ei) ei)) (entupd e))) (princ)) (alert "Çizimdeki tüm attributler değiştirilecek!!!") (setq addreal (getreal "\nEklenecek sayıyı giriniz: ")) (if (= addreal nil) (setq addreal -6)) (AddNumAtt addreal "*") ;(AddNumAtt 1.00 "*") (alert "find penceresi açıldığında \"+-\" leri arattırın ve\"-\" ile değiştirtin!!!") (command "find") ; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.