Jump to content

Recommended Posts

Posted

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

Posted (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 by Tharwat
codes updated
Posted

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

Posted

That's right Mircea .

 

Thank you , Codes updated . :)

 

Regards,

Tharwat

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...