Advertisement
ArthurGanem

AG Simple Addition

Oct 28th, 2017 (edited)
2,954
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;|------------------------------|;
  2. ;|  AG Simple Addition  |;
  3. ;|  www.ArthurGanem.com |;
  4. ;|------------------------------|;
  5.  
  6.  
  7. ;|
  8.  
  9.  
  10. 1)  Command: SIMADD
  11. 2)  Click text object (MTEXT or TEXT) you want to add.
  12. 3)  Click text object you want to add.
  13. 4)  Click text object in which you want to display the total.
  14.  
  15. |;
  16.  
  17. (prompt "\nLoaded AG Simple Addition!")
  18.  
  19. (defun c:simadd(/ mspace loop selection xselection number1 number2 total)
  20.  
  21.   (vl-load-com)
  22.  
  23.   (setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
  24.  
  25.   (setq loop 1)
  26.  
  27.   (while (= loop 1)
  28.     (setq selection (entsel "\nSelect the number you want to add --> \n"))
  29.    
  30.     (if (/= selection nil)
  31.       (progn
  32.       (setq xselection (vlax-ename->vla-object (car selection)))
  33.       (if (or (= (vla-get-ObjectName xselection) "AcDbText") (= (vla-get-ObjectName xselection) "AcDbMText"))
  34.         (progn
  35.           (setq number1 (atoi (vla-get-TextString xselection)))
  36.           (setq loop 0)
  37.           ) ;progn
  38.         ) ;if
  39.       ) ;progn
  40.     ) ;if
  41.     ) ;while
  42.  
  43.   (setq loop 1)
  44.  
  45.   (while (= loop 1)
  46.     (setq selection (entsel "\nSelect the second number you want to add --> \n"))
  47.    
  48.     (if (/= selection nil)
  49.       (progn
  50.       (setq xselection (vlax-ename->vla-object (car selection)))
  51.       (if (or (= (vla-get-ObjectName xselection) "AcDbText") (= (vla-get-ObjectName xselection) "AcDbMText"))
  52.         (progn
  53.           (setq number2 (atoi (vla-get-TextString xselection)))
  54.           (setq loop 0)
  55.           ) ;progn
  56.         ) ;if
  57.       ) ;progn
  58.     ) ;if
  59.     ) ;while
  60.  
  61.   (setq loop 1)
  62.  
  63.   (while (= loop 1)
  64.     (setq selection (entsel "\nSelect TXT or MTEXT to which you want to input the total -->"))
  65.    
  66.     (if (/= selection nil)
  67.       (progn
  68.       (setq xselection (vlax-ename->vla-object (car selection)))
  69.       (if (or (= (vla-get-ObjectName xselection) "AcDbText") (= (vla-get-ObjectName xselection) "AcDbMText"))
  70.         (progn
  71.           (setq total (+ number1 number2))
  72.           (vla-put-TextString xselection (itoa total))
  73.           (setq loop 0)
  74.           ) ;progn
  75.         ) ;if
  76.       ) ;progn
  77.     ) ;if
  78.     ) ;while
  79.  
  80.  
  81.  
  82.   (princ)
  83.   )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement