Guest balajibth84 Posted October 5, 2010 Share Posted October 5, 2010 Hai here Balaji...I want one doubt.....Please See the below example..IN Dwg below mentioned number available...I want Add(Plus) this 3 numbers..Now i am selecting this 3 numbers and give Add command means result (19.52)should be come on in command dialogue box....no need create any out file like txt...I want display that output value in inside of the dwg anywhere(Like in commdline pallet or dialog box in cad file anywhere).....Can u help me for this lisp???please???I want this for add,divide,and multiple calculation.... 9.42 8.52 1.58 Link to comment Share on other sites More sharing options...
BIGAL Posted October 5, 2010 Share Posted October 5, 2010 Heres a start this just adds a value to existing text this is an example of how you could do the other things you mentioned by improving the code. ;Adds a fixed amount to a number (PRINC "TO USE JUST TYPE A2L") (DEFUN c:A2L () (setvar "cmdecho" 1) (setq v2 (getreal "\nEnter ht adjustment ")) (setq test 1) (while (= test 1) (setq en1 (car (entsel "\nSelect text number:" ))) (if (/= en1 nil) (progn (setq el1 (entget en1)) (setq v1 (atof (cdr (assoc 1 el1)))) ; this returns the value of the existing text (setq a (+ v1 v2)) ; add difference to old (setq b (rtos a 2 3)) ; convert to a string (setq el (subst (cons 1 b) (assoc 1 el1) el1)) ;update text (entmod el) ) ; end progn (princ "\nplease pick again"); else ) ; end if ); while true (setq el nil) (setq en nil) (setq a nil) (setq v1 nil) (setvar "cmdecho" 1) ); END DEFUN (princ) The next step would be to change it to use "ssget" which would make a list of multiple text by one pick to do something with. Also need a check for "mtext" Link to comment Share on other sites More sharing options...
alanjt Posted October 5, 2010 Share Posted October 5, 2010 Combinevalues [Add/Divide/Multiply/Subtract object values] Link to comment Share on other sites More sharing options...
Guest balajibth84 Posted October 5, 2010 Share Posted October 5, 2010 Calculation.dwg Heres a start this just adds a value to existing text this is an example of how you could do the other things you mentioned by improving the code. ;Adds a fixed amount to a number (PRINC "TO USE JUST TYPE A2L") (DEFUN c:A2L () (setvar "cmdecho" 1) (setq v2 (getreal "\nEnter ht adjustment ")) (setq test 1) (while (= test 1) (setq en1 (car (entsel "\nSelect text number:" ))) (if (/= en1 nil) (progn (setq el1 (entget en1)) (setq v1 (atof (cdr (assoc 1 el1)))) ; this returns the value of the existing text (setq a (+ v1 v2)) ; add difference to old (setq b (rtos a 2 3)) ; convert to a string (setq el (subst (cons 1 b) (assoc 1 el1) el1)) ;update text (entmod el) ) ; end progn (princ "\nplease pick again"); else ) ; end if ); while true (setq el nil) (setq en nil) (setq a nil) (setq v1 nil) (setvar "cmdecho" 1) ); END DEFUN (princ) The next step would be to change it to use "ssget" which would make a list of multiple text by one pick to do something with. Also need a check for "mtext" I tried in cad 2007 this lisp...its not working ....i am asking for adding the text...Just for sample In dwg some text is availble(Numeric). Like 1 23 10 14 Just i want Plus this text(Whatever text i am selecting using tracking method that text only)... 1+23+10+14=48 Here i want this output text "48"...Its display means enough..We will see that output text and we will enter manually.....Same i want multiple also... 1*23*10*14=3220.. I dont want create any output file like .txt or .xls....That output can display(Whatever text i am selecting using tracking method that text only)... in cad means that is well enough for me....Now I think you are understand...Thanks in advance.... Note:For ref here i have attached one sample dwg also... Link to comment Share on other sites More sharing options...
ReMark Posted October 5, 2010 Share Posted October 5, 2010 You want to add text. You want to multiple text. You want the result to be displayed on the command line and not sent to a file. And you want to do either arithmetic function using a lisp routine. Are all four statements correct? Link to comment Share on other sites More sharing options...
ReMark Posted October 5, 2010 Share Posted October 5, 2010 Take a look at this lisp routine called Mathtext which allows the user to perform mathematical functions on text or MText entities. http://cadtips.cadalyst.com/notestext/run-calculations-numerical-text-and-mtext This routine just adds text and assigns the sum to another text entity within the drawing. http://cadtips.cadalyst.com/inquiry/add-numbers Link to comment Share on other sites More sharing options...
Guest balajibth84 Posted October 5, 2010 Share Posted October 5, 2010 (edited) Take a look at this lisp routine called Mathtext which allows the user to perform mathematical functions on text or MText entities. http://cadtips.cadalyst.com/notestext/run-calculations-numerical-text-and-mtext This routine just adds text and assigns the sum to another text entity within the drawing. http://cadtips.cadalyst.com/inquiry/add-numbers Hai Remark i am got the lisp from your mentioned link..As per this lisp for output i want select one text...then only that out is updating to that selected text....And after my selected text is going to Addnum layer automatically.....Now i want just two thinks.... 1)One is i want a displaying the output(No need to update that out put to other text)...and 2)second one is after calculation my selected text layer no need to change....as per that text layer its should be maintain same layer....this two things i want include here..can you edit this things??? (defun C:ADNUM (/ ENT CT ANX AN SNUM SLEN E EE X OL NL ENT2) ;(command "LAYER" "N" "ADDNUM" "") (prompt "\nPick numbers to add: ") (setq ENT (ssget)) (setq CT 0 ANX 0 AN 0) (setq SNUM (ssname ENT CT)) (setq SLEN (sslength ENT)) (while (<= (1+ CT) SLEN) (setq SNUM (ssname ENT CT)) (setq E (entget SNUM)) (setq EE (cdr (assoc 1 E))) (setq X (atof EE)) (setq OL (assoc 8 E)) (setq NL (cons 8 "ADDNUM")) (setq ENT2 (subst NL OL E)) (entmod ENT2) (setq ANX (+ AN X)) (setq AN ANX) (setq CT (1+ CT)) ) ;(princ "\nTotal = ") (setq tot (strcat (rtos ANX 2 2))) (setq sel1 (entsel "\nSelect NUMBER TO CHANGE: ")) (setq ent1 (car sel1)) (setq edata (entget ent1)) (setq t1 (cdr (assoc 1 edata)));FOR TEXT VALUE (setq c (cdr (assoc 62 edata)));FOR COLOR (setq l (cdr (assoc 8 edata))) ;FOR LAYER (setq s (cdr (assoc 7 edata))) ;FOR STYLE (setq f (cdr (assoc 4 edata))) ;FOR FONT (setq h (cdr (assoc 40 edata))) ;FOR HEIGHT (setq w (cdr (assoc 41 edata))) ;FOR WIDTH (setq a (angtos (cdr (assoc 50 edata)) 0 4)) ;FOR ROTATION ANGLE (setq in (cdr (assoc 10 edata))) ; for insertion point (setvar "cmdecho" 1) (command "erase" sel1 "") (Command "_style" s "" h w "" "" "" "") (COMMAND "COLOR" c) (COMMAND "CLAYER" l) (command "text" in "0" tot) ) Edited October 5, 2010 by Tiger added code tags Link to comment Share on other sites More sharing options...
ReMark Posted October 5, 2010 Share Posted October 5, 2010 Add and subtract selected numerical text entities using the lisp routine shown here: http://cadtips.cadalyst.com/notestext/add-and-subtract-selected-numbers Link to comment Share on other sites More sharing options...
Guest balajibth84 Posted October 5, 2010 Share Posted October 5, 2010 Ya i am got it.....thanks a Lottttttt.....Remark Link to comment Share on other sites More sharing options...
ReMark Posted October 5, 2010 Share Posted October 5, 2010 Ya i am got it.....thanks a Lottttttt.....Remark Did you try out Alan's lisp routine? Link to comment Share on other sites More sharing options...
Guest balajibth84 Posted October 5, 2010 Share Posted October 5, 2010 I am tried add and subtraction lisp only......Alan"s means may i knwo what is that???? Link to comment Share on other sites More sharing options...
ReMark Posted October 5, 2010 Share Posted October 5, 2010 I am tried add and subtraction lisp only......Alan"s means may i knwo what is that???? Not sure how you missed CombineValues.lsp in post #3. Link to comment Share on other sites More sharing options...
Guest balajibth84 Posted October 5, 2010 Share Posted October 5, 2010 Not sure how you missed CombineValues.lsp in post #3. Can you tell the Exact Topic name???I will try to find man please.. Link to comment Share on other sites More sharing options...
alanjt Posted October 5, 2010 Share Posted October 5, 2010 Can you tell the Exact Topic name???I will try to find man please.. I posted a direct link and a video. Link to comment Share on other sites More sharing options...
ReMark Posted October 5, 2010 Share Posted October 5, 2010 Can you tell the Exact Topic name???I will try to find man please.. Would a compass help? The topic is the one we are in right now (Calculator for Adding and Multiple...). It doesn't get much easier than that. Post numbers are found in the upper right-hand corner of each post. This should be post #15. You want Page 1...post #3. It shouldn't be too difficult to find. Link to comment Share on other sites More sharing options...
Guest balajibth84 Posted October 5, 2010 Share Posted October 5, 2010 Would a compass help? The topic is the one we are in right now (Calculator for Adding and Multiple...). It doesn't get much easier than that. Post numbers are found in the upper right-hand corner of each post. This should be post #15. You want Page 1...post #3. It shouldn't be too difficult to find. I am not getting you.......I am got the lisp for Add(Plus)....I am expect for multiple(LIke 2*3=6)..Same like as add lisp...Using tracking method.... now remark.................... Link to comment Share on other sites More sharing options...
ReMark Posted October 5, 2010 Share Posted October 5, 2010 I give up. By the way, the word is multiply not multiple. You want to multiply two numbers. Link to comment Share on other sites More sharing options...
alanjt Posted October 5, 2010 Share Posted October 5, 2010 This is my last attempt to help: Go back and read ALL posts, click on ALL links, watch ALL posted example videos. Link to comment Share on other sites More sharing options...
Guest balajibth84 Posted October 6, 2010 Share Posted October 6, 2010 I give up. By the way, the word is multiply not multiple. You want to multiply two numbers. Ya i want that Multiply the two numbers or selected text (More than two Texts) Link to comment Share on other sites More sharing options...
ReMark Posted October 6, 2010 Share Posted October 6, 2010 I must be a machocist to continue with this conversation. To multiply two numbers that appear as text in a drawing use one of the two following methods: 1) Combinevalues.lsp [Add/Divide/Multiply/Subtract object values as written by forum member alanjt. ...or... 2) Use the Mathtext lisp routine I provided a link for previously. At this time those are the only two methods I am aware of. Perhaps if you check other sources (ex. - AUGI website) you might find another lisp routine that will do numerical calculations using text entities. Link to comment Share on other sites More sharing options...
Recommended Posts