Legal
notices:
- This sample program is intended as a demonstration only.
- The program is available on an 'as-is' basis with no warranties,
either expressed or implied, of any kind.
- You may use the program only at your own risk.
- No license or rights to the program are either given or forfeited.
Everything that follows is direct and unaltered output from the LISP
Generator.
; This program was created on October 24 2006 using the LISP
Generator.
; Define the function (the program).
(defun c:GEAR ( / PT1 RAD1 CIRCUM NUM1 XSCALE LEN1 ANG1 I ROT1 PT2
OLDCE OLDERR OLDTE)
; Save the current value of cmdecho then redefine it.
(setq OLDCE (getvar "cmdecho"))
(setvar "cmdecho" 1)
; Save the current value of texteval then set it to 1
(setq OLDTE (getvar "texteval"))
(setvar "texteval" 1)
; Save the current value of the error handling subroutine then
redefine it.
(setq OLDERR *error*)
(defun *error* (errmes)
(princ (strcat "\nExecution of GEAR halted by the
following error: " ERRMES))
(setvar "cmdecho" OLDCE)
(setq *error* OLDERR)
(prin1)
)
;(setq *error* nil)
; NOTE: to turn error handling off, erase the semicolon in the
line above.
; GET a POINT from the user and store it in PT1. 
(setq PT1 (getpoint "\ncenter point: "))
; GET a DIST from the user and store it in RAD1.
(setq RAD1 (getdist "\nradius: "))
; assign result of MATH calculation to CIRCUM.
(setq CIRCUM (* (* 2 PI) RAD1))
; GET a INT from the user and store it in NUM1.
(setq NUM1 (getint "\nnumber of gears: "))
; assign result of MATH calculation to XSCALE.
(setq XSCALE (/ (/ CIRCUM NUM1) 2))
; GET a DIST from the user and store it in LEN1. 
(setq LEN1 (getdist "\nlength of tooth: "))
; ASSIGN a value to ANG1.
(setq ANG1 0)
; BEGIN LOOP loop1.
; LOOP NUM1 times.
(setq I -1)
(repeat NUM1
(setq I (1+ I))
; assign result of MATH calculation to ANG1. 
(setq ANG1 (/ (* I 360.0) NUM1))
; assign result of MATH calculation to ROT1.
(setq ROT1 (+ ANG1 270.0))
; OPERATION - store the result in PT2.
(setq PT2 (POLAR PT1 (/ (* ANG1 PI) 180.0) RAD1))
; Input to AutoCAD's command line.
(command
"insert"
"tooth"
PT2
XSCALE
LEN1
ROT1
)
) ; END LOOP loop1.
; Reset "cmdecho" to previous value. 
(setvar "cmdecho" OLDCE)
; Reset "texteval" to previous value.
(setvar "texteval" OLDTE)
; Reset *error* to previous definition.
(setq *error* OLDERR)
; Exit quietly (no return value.)
(prin1)
)