prapti Posted January 20, 2011 Posted January 20, 2011 Hi, I am searching LISP for Selecting text "A" value and Text "B" value and click on "C" text, then Text "C" automatically should be update as (A-B) as this formula. for Ex. Text A is "17.010" and Text B is "14.668" if you Select text "A" and Select text "B" and the Select "C" value is automatically updated as "2.342" It means (A-B)= C (17.010-14.668)= 2.342 Value should be re requere up to 3 desimals. Is this possible Thanks Quote
Tharwat Posted January 20, 2011 Posted January 20, 2011 (edited) This may help you with it . If you mess clicking on a text it will return from the beginning ( read the command line while invoking the routine) (defun c:sub (/ ss1 ss2 ss3 st1 st2 st3 e) ; Tharwat 20.01.2011 (while (not (and (setq ss1 (car (entsel "\n Select first text to subtract from :"))) (setq ss2 (car (entsel "\n Select second text :"))) (setq ss3 (car (entsel "\n Select text to insert the result:"))) )) ) (progn (setq st1 (cdr (assoc 1 (entget ss1)))) (setq st2 (cdr (assoc 1 (entget ss2)))) (setq st3 (cdr (assoc 1 (setq e (entget ss3))))) (entupd (cdr (assoc -1 (entmod (subst (cons 1 (rtos (- (distof st1) (distof st2)) 2 3)) (assoc 1 e) e) ) ) ) ) ) (princ) ) Edited January 20, 2011 by Tharwat codes updated Quote
MSasu Posted January 20, 2011 Posted January 20, 2011 One comment, the OP requested for a double with 3 decimals as a result, so you may want to use DISTOF instead of ATOI in your code; this function will allow you also to validate the content of the string. The same for ITOA vs. RTOS. Thank you. Regards, Mircea Quote
Tharwat Posted January 20, 2011 Posted January 20, 2011 That's right Mircea . Thank you , Codes updated . Regards, Tharwat Quote
alanjt Posted January 20, 2011 Posted January 20, 2011 http://www.cadtutor.net/forum/showthread.php?46688-Combinevalues.LSP-Add-Divide-Multiply-Subtract-object-values Quote
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.