Visual LISP, AutoLISP and General Customization
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
need lisp that will sum selected text values
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Re: need lisp that will sum selected text values
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
(defun c:calc()
(initget "+ - * /")
(setq app(getkword "\nWhat application would you like to do:\(+,-,*,/)"))
(if(or (= app "-")(= app "/"))(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 "+")
(addc))
((= app "-")
(subc))
((= app "*")
(multc))
((= app "/")
(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 1))(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))
)
)
Tim
Re: need lisp that will sum selected text values
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Re: need lisp that will sum selected text values
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hai..
I am very sorry to say it is not working in Autocad2008
Re: need lisp that will sum selected text values
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Maybe you are using Mtext with formatting
Re: need lisp that will sum selected text values
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Mr Willy
I could find what i want. but it is not working. The error is - Select objects: ; error: bad argument type: lselsetp nil. please rectify this code for me. Iam using Autocad2008. It will very usefull to me. Thank you.
Re: need lisp that will sum selected text values
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Select objects: ; error: bad argument type: lselsetp nil.
That means incorrect Data type. So.. agaim, are you using MTEXT?
Re: need lisp that will sum selected text values
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
*Michael Pape & Associates wrote:
Can someone steer me ... to a lisp routine that will add together the values of text entities?....
Another approach:
http://cadtips.cadalyst.com/list/sum-values-text-s
I don't see anything in the description that mentions Mtext, and I haven't downloaded it, so it may also work only with Text entities.
Re: need lisp that will sum selected text values
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Re: need lisp that will sum selected text values
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Kent1Cooper wrote:I don't see anything in the description that mentions Mtext, and I haven't downloaded it, so it may also work only with Text entities.
Exactly my point. as the error mesage indicate as such
pbejse wrote:That means incorrect Data type. So.. agaim, are you using MTEXT?This is me short of tellimg the OP his trying to use the porogram with Mtext entities, but apparently the OP directing the question to the orignal author of the code.
Oh well,..
Nice tip BTW



