Jump to content

Calculator for Adding and Multiple


Guest balajibth84

Recommended Posts

Guest balajibth84

Hai here Balaji...I have lisp for Divide and Multiple the selected text.....i want edit that lisp(Divide and Divide Lisp) easily like my below mentioned Add and Subtraction lisp..Can you help me???

 

This is My add and subtraction lisp for your reference......

(defun C:ADD (/ S1 LG INDEX A B C D)
 (setq S1    (ssget)
       LG    (sslength S1)
       INDEX 0
       C     0
 ) ;_ end of setq
 (while (/= INDEX LG)
   (setq A (entget (ssname S1 INDEX))
         D (cdr (assoc 0 A))
   ) ;_ end of setq
   (if (= D "TEXT")
     (progn
       (setq B (atof (cdr (assoc 1 A)))
             C (+ C B)
       ) ;_ end of setq
     ) ;_ end of progn
   ) ;_ end of if
   (setq INDEX (1+ INDEX))
 ) ;_ end of while
 (princ "\nTotal Value: ")
 (princ C)
 (princ)
)   ;end defun


(defun C:SUB (/ MS ML INDEXM CM MA MD MB CM S LG INDEX
             A B C C1 D
            )
 (prompt "SELECT the MAIN Number(s): ")
 (setq MS     (ssget)
       ML     (sslength MS)
       INDEXM 0
       CM     0
 ) ;_ end of setq
 (while (/= INDEXM ML)
   (setq MA (entget (ssname MS INDEXM))
         MD (cdr (assoc 0 MA))
   ) ;_ end of setq
   (if (= MD "TEXT")
     (progn
       (setq MB (atof (cdr (assoc 1 MA)))
             CM (+ CM MB)
       ) ;_ end of setq
     ) ;_ end of progn
   ) ;_ end of if
   (setq INDEXM (1+ INDEXM))
 ) ;_ end of while
 (prompt "\nSelect the NUMBERS to be DUDUCTED: ")
 (setq S     (ssget)
       LG    (sslength S)
       INDEX 0
       C     0
 ) ;_ end of setq
 (while (/= INDEX LG)
   (setq A (entget (ssname S INDEX))
         D (cdr (assoc 0 A))
   ) ;_ end of setq
   (if (= D "TEXT")
     (progn
       (setq B (atof (cdr (assoc 1 A)))
             C (+ C B)
       ) ;_ end of setq
     ) ;_ end of progn
   ) ;_ end of if
   (setq INDEX (1+ INDEX))
 ) ;_ end of while
 (setq C1 (- CM C))
 (princ "\nNett value: ")
 (princ C1)
 (princ)
   ; --------------------------------------------------------------------
)   ;---end defun 

 

AS per above "Add and Subtraction" lisp i want change(Easily select and execute the output in Command pallete) the below mentioned my "Divide and Multiple"Lisp....PLease remove the Add and Sub option from the below mentioned my lisp....And give only "Divide and Multiple" option......

 

(defun c:mathtext
      (/ *error* mt:doc mt:fail mt:set mt:symb mt:text mt:val mt:dimzin)

;;;------------------------------------------------------------------------------------
   (defun *error* (msg)
       (princ msg)
       (setvar 'dimzin mt:dimzin)
       (and mt:doc (vla-endundomark mt:doc))
       (setvar 'cmdecho 1)
   ) ;_ end_defun

;;;------------------------------------------------------------------------------------
   (setvar 'cmdecho 0)
   (vl-load-com)
   (setq mt:doc (vla-get-activedocument (vlax-get-acad-object)))
   (vla-endundomark mt:doc)
   (vla-startundomark mt:doc)
   (setq mt:dimzin (getvar 'dimzin))
   (setvar 'dimzin 1)
   (prompt "\n>>>...Select Text to Compute...<<<")
   (if (setq mt:set (ssget ":L" '((0 . "TEXT,MTEXT"))))
       (progn
           (initget 6 "+ - * /")
           (setq mt:symb
                    (getkword "\n...Whick Operation?...\n[+/-/*//]<+>: ")
           ) ;_ end_setq
           (or mt:symb (setq mt:symb "+"))
           (initget 1)
           (setq mt:val
                    (cond
                        ((eq mt:symb "+") (getreal "\n...Enter Addend...: "))
                        ((eq mt:symb "-") (getreal "\n...Enter Subtrahend...: "))
                        ((eq mt:symb "*") (getreal "\n...Enter Multiplier...: "))
                        ((eq mt:symb "/") (getreal "\n...Enter Divisor...: "))
                    ) ;_ end_cond
           ) ;_ end_setq
           (or mt:dec (setq mt:dec 3))
           (setq mt:dectemp
                    (getint (strcat "\n...Enter No. of Decimal Places...<"
                                    (itoa mt:dec)
                                    ">: "
                            ) ;_ strcat
                    ) ;_ getint
           ) ;_ setq
           (and mt:dectemp (setq mt:dec mt:dectemp))
           (setq mt:fail 0)
           (mapcar
               '(lambda (x)
                    (if
                        (numberp
                            (read
                                (setq mt:text
                                         (vla-get-textstring x)
                                ) ;_ end_setq
                            ) ;_ end_read
                        ) ;_ end_numberp
                           (vla-put-textstring
                               x
                               (rtos
                                   (apply
                                       (read mt:symb)
                                       (list
                                           (atof mt:text)
                                           mt:val
                                       ) ;_ end_list
                                   ) ;_ end_apply
                                   2
                                   mt:dec
                               ) ;_ end_rtos
                           ) ;_ end_vla-put-textstring
                           (setq mt:fail (1+ mt:fail))
                    ) ;_ end_if
                ) ;_ end_lambda
               (mapcar 'vlax-ename->vla-object
                       (vl-remove-if
                           'listp
                           (mapcar 'cadr
                                   (ssnamex mt:set)
                           ) ;_ end_mapcar
                       ) ;_ end_vl-remove-if
               ) ;_ end_mapcar
           ) ;_ end_mapcar
       ) ;_ end_progn
   ) ;_ end_if

   (prompt
       (strcat "\n\"..."
               (itoa (- (sslength mt:set) mt:fail))
               " Text Objects were Replaced...\"\n"
       ) ;_ strcat
   ) ;_ end_prompt
   (*error* "")
   (princ)
) ;_ end_defun
(prompt
   "\n>>>...Mathtext.Lsp is now Loaded, Type 'Mathtext'to Start Routine...<<<\n"
) ;_ prompt
(princ)
;;;------------------------------------------------------------------------------------

 

 

Can you edit this lisp(Multiple and Divide Lisp)?????Thanks in Advance....

Edited by CADTutor
[CODE] tags added
Link to comment
Share on other sites

  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

  • ReMark

    19

  • Cad64

    5

  • alanjt

    4

  • CADTutor

    2

Top Posters In This Topic

Guest balajibth84

My Thread posting method is wrong???any problem for this Thread????i am waiting for that "Divide and Multiple"Lisp.....

Link to comment
Share on other sites

Guys, we are a welcoming, patient and tolerant community. Not all new members understand the correct method of presenting code but if someone would like to write a short tutorial, we can sticky it for all to see in the future. In the meantime, I added the

 tags to the offending post. :)
Link to comment
Share on other sites

My Thread posting method is wrong???any problem for this Thread????i am waiting for that "Divide and Multiple"Lisp.....

 

1) Please and Thank you go a long way.

 

2) There is a difference bewteen requesting help and expecting someone to drop what they are doing just to attend to your needs.

 

3) Patience is a virtue. Nagging is frowned upon.

Link to comment
Share on other sites

The OP is a tough sell. I've had similar conversations with him over the topic of Excel spreadsheets and AutoCAD 2007. Either he doesn't read all the posts or he doesn't quite understand them but it takes a lot of patience and the repeating of previous statements before the concept of what is trying to be conveyed sinks in. Just search "Excel"+"AutoCAD 2007" to see what I'm talking about.

Link to comment
Share on other sites

Ok, maybe you're right in this case. It's just that I get a lot of emails from visitors to the site and many of them seem to be demanding stuff; "teach me AutoCAD", "send me all the software I need", "send me all your videos on DVD", "give me a job" - I'm not making this up. At first I thought this was just rude but I've come to realise that it is a result of cultural differences and language. As the Web becomes ever more "global", this sort of thing will be more common and we have to learn to deal with it rather than be offended by it.

 

Now I've finished my sermon and annoyed everyone by rudely hijacking this thread, I'll duck out. :oops:

Link to comment
Share on other sites

it's all gone offtopic but atljant (I thought it was him) teached me to use 'cal to do calculations in autocad.

Link to comment
Share on other sites

Guest balajibth84
Or how about a calculator. I have one sitting right next to my mouse. :P

Or is that too old school? :?

 

Hai i am expect this multiple and divide lisp yaar

Link to comment
Share on other sites

Hai i am expect this multiple and divide lisp yaar

 

I'm not sure what you are asking. The last word makes no sense either. What are you seeking?

Link to comment
Share on other sites

Guest balajibth84
Hai i am expect this multiple and divide lisp yaar

 

I'm not sure what you are asking. The last word makes no sense either. What are you seeking?

 

I want a lisp for Multiple and divide the selected text...I have the lisp for add and subtraction...I want same like for "Divide and Multiple"

 

 

 

This is For u r ref:

 

(defun C:ADD (/ S1 LG INDEX A B C D)
 (setq S1    (ssget)
       LG    (sslength S1)
       INDEX 0
       C     0
 ) ;_ end of setq
 (while (/= INDEX LG)
   (setq A (entget (ssname S1 INDEX))
         D (cdr (assoc 0 A))
   ) ;_ end of setq
   (if (= D "TEXT")
     (progn
       (setq B (atof (cdr (assoc 1 A)))
             C (+ C B)
       ) ;_ end of setq
     ) ;_ end of progn
   ) ;_ end of if
   (setq INDEX (1+ INDEX))
 ) ;_ end of while
 (princ "\nTotal Value: ")
 (princ C)
 (princ)
)   ;end defun


(defun C:SUB (/ MS ML INDEXM CM MA MD MB CM S LG INDEX
             A B C C1 D
            )
 (prompt "SELECT the MAIN Number(s): ")
 (setq MS     (ssget)
       ML     (sslength MS)
       INDEXM 0
       CM     0
 ) ;_ end of setq
 (while (/= INDEXM ML)
   (setq MA (entget (ssname MS INDEXM))
         MD (cdr (assoc 0 MA))
   ) ;_ end of setq
   (if (= MD "TEXT")
     (progn
       (setq MB (atof (cdr (assoc 1 MA)))
             CM (+ CM MB)
       ) ;_ end of setq
     ) ;_ end of progn
   ) ;_ end of if
   (setq INDEXM (1+ INDEXM))
 ) ;_ end of while
 (prompt "\nSelect the NUMBERS to be DUDUCTED: ")
 (setq S     (ssget)
       LG    (sslength S)
       INDEX 0
       C     0
 ) ;_ end of setq
 (while (/= INDEX LG)
   (setq A (entget (ssname S INDEX))
         D (cdr (assoc 0 A))
   ) ;_ end of setq
   (if (= D "TEXT")
     (progn
       (setq B (atof (cdr (assoc 1 A)))
             C (+ C B)
       ) ;_ end of setq
     ) ;_ end of progn
   ) ;_ end of if
   (setq INDEX (1+ INDEX))
 ) ;_ end of while
 (setq C1 (- CM C))
 (princ "\nNett value: ")
 (princ C1)
 (princ)
   ;

Edited by Tiger
added code-tags
Link to comment
Share on other sites

Let's start with this simple question. Have you tried the lisp routine that Alan posted much earlier in this thread? Yes or No?

Link to comment
Share on other sites

Guest balajibth84
Let's start with this simple question. Have you tried the lisp routine that Alan posted much earlier in this thread? Yes or No?

 

Ya i am tried...But its not easy like that my given add and subtraction lisp....So only i am asking...This add and subtraction also i am taken from that link only..........

Link to comment
Share on other sites

Thank you for your reply.

 

I do not know of any other lisp routines other than the ones I have already mentioned.

 

Is that clear?

Link to comment
Share on other sites

Guest balajibth84
Thank you for your reply.

 

I do not know of any other lisp routines other than the ones I have already mentioned.

 

Is that clear?

 

Hai Remark i am cleared....Just look that my above mentioned lisp(Add and Subtraction)..Just single click i can add and subtration that...But for multiple and divide its asking more question(More info i want to Give)...So only i am asking the Multiple and Divide lisp like simply using method........

Link to comment
Share on other sites

If I understand you correctly you would like to simplify the Multiply and Divide lisp so it acts more like the Add and Subtract lisp. Is that right?

 

What is it that you do not like about the Multiply and Divide lisp exactly?

 

I have not tested the lisp routine myself so I do not know what questions it is asking.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...