- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
can anyone help me revise this routine so that the multiply function is the default so I don't have to type "M" to activate it?
also, the default is replacing the existing text with the answer. thank you
(defun c:cal()
(initget "A S M D")
(setq app(getkword "\nWhat application would you like to do:\(Add,Subtract,Multiply,Divide)"))
(if(or (= app "S")(= app "D"))(princ "\nDon't forget order counts. So pick carefully."))
(princ "\nSelect numbers to calculate:")
(setq cal(ssget '((0 . "TEXT"))))
(setq n 0)
(setq l(sslength cal))
(while(/= l n)
(get_info)
(if(= nu3 0.0)
(progn
(ssdel (ssname cal n) cal)
(setq l(- l 1))
(setq n(- n 1))
)
)
(setq n(+ n 1))
)
(setq n 0)
(setq l(sslength cal))
(cond
((= app "A")
(addc))
((= app "S")
(subc))
((= app "M")
(multc))
((= app "D")
(divdc))
)
;(initget "Replace Write")
;(princ "\nAnswer= ")
;(princ nu5)
;(setq tx1(getkword"\nWhat do you want do with the answer\(Replace, Write to screen):"))
;(cond
;((= tx1 "Replace")
(setq tx2(ssget '((0 . "TEXT"))))
(setq n 0)
(setq l(sslength tx2))
(while(/= n l)
(setq tx3(entget(ssname tx2 n)))
(setq tx4(subst(cons 1 (rtos nu5 2 2))(assoc 1 tx3) tx3))
(entmod tx4)
(setq n(+ 1 n))
)
)
;((= tx1 "Write")
;(setq nu5(rtos nu5 2 1))
;(command "layer" "m" "sr_text_n" "c" "3" "" "")
;(command "textstyle" "sr-romands2")
(princ "\nPick point for text insertion")
;(command "text" "j" "m" pause "" "" nu5 )
😉
😉
(princ)
😉
(defun get_info()
(setq nu1(entget (ssname cal n)))
(setq nu2(cdr(assoc 1 nu1)))
(setq nu3(atof nu2))
)
(defun addc()
(get_info)
(setq nu4 nu3)
(setq n(+ 1 n))
(while(/= l n)
(get_info)
(setq nu5(+ nu4 nu3))
(setq nu4 nu5)
(setq n(+ 1 n))
)
)
(defun subc()
(get_info)
(setq nu4 nu3)
(setq n(+ 1 n))
(while(/= l n)
(get_info)
(setq nu5(- nu4 nu3))
(setq nu4 nu5)
(setq n(+ 1 n))
)
)
(defun multc()
(get_info)
(setq nu4 nu3)
(setq n(+ 1 n))
(while(/= l n)
(get_info)
(setq nu5(* nu4 nu3))
(setq nu4 nu5)
(setq n(+ 1 n))
)
)
(defun divdc()
(get_info)
(setq nu4 nu3)
(setq n(+ 1 n))
(while(/= l n)
(get_info)
(setq nu5(/ nu4 nu3))
(setq nu4 nu5)
(setq n(+ 1 n))
)
)
Solved! Go to Solution.