Thursday, July 25, 2013

List Auto programming for arithmetic operations by Budi Maryanto, ST


 Arithmetic operations is one thing that is essential in the mechanical engineering drawing, drawing both manually and by using AUTO CAD. AUTO CAD basically does not provide this facility, to draw, but AUTO CAD provides LIST AUTO as default device, which serves to accelerate the process performance when we're drawing techniques with AUTO CAD

Below is a list form AUTO program for calculating arithmetic operations.

To be able to use it
1. Vlisp type in the command window, so the window will open consule
2. type in the following program on consule window

; Program to select the arithmetic operation
; Initget and input using keywords
(defun c: denbagus (/ bil1 bil2 op simOp HSL)
   (initget 1)
   (setq bil1 (getreal "\ nMasukan first number, bro:"))
   (initget (+ 1 2)); zero is not allowed, because bil2 is a divider in operation for
   (setq bil2 (getreal "\ nMasukan second number, bro:"))
   (initget 1 "ONCE, FOR K, B ADDED, LESS T, K")
   (setq op (getkword "\ nChoose arithmetic operations, bro [Kali / Share / Add / less]:"))
   (cond
     ((= Op "TIMES") (setq HSL (* bil1 bil2) simOp "*"))
     ((= Op "FOR") (setq HSL (/ bil1 bil2) simOp "/"))
     ((= Op "ADD") (setq HSL (+ bil1 bil2) simOp "+"))
     ((= Op "LESS") (setq HSL (- bil1 bil2) simOp "-"))
     (T)
     ); _cond
   (princ (strcat "\ n" (rtos bil1 2 2) simOp (rtos bil2 2 2) "=" (rtos HSL 2 2)))
     (princ)
   )
(princ)

3. Click the button to run it load
4. back to Auto Cad denbagus type in the command window and follow the prompts
its in the command window
5. AUTO CAD will display the results of arithmetic operations

No comments: