Visual LISP, AutoLISP and General Customization

## Visual LISP, AutoLISP and General Customization

Active Member
Posts: 9
Registered: ‎08-23-2012
Message 1 of 2 (208 Views)

# Insert circles Lisp

208 Views, 1 Replies
01-24-2013 09:45 AM

Am trying to put up a lisp routine to plot a couple a circles along the circumference of the cylinder(when its is develpoed flat). But the routine fails:

(defun c:cir ()
(setq rad (getreal "\nDiameter of the holes: "))
(setq dia (getreal "\nCylinder diameter: "))
(setq numb (getint "\nHoles needed: "))
(setq pt (getpoint "\nCircle centre point : "))
(setq pie 3.142)
(setq dist (/ *(pie dia) num)))
(setq counter 0)
(while (< counter numb)
(setq pt (polar pt 0 dist))
(setq counter (+ 1 counter)))

*Expert Elite*
Posts: 5,872
Registered: ‎09-13-2004
Message 2 of 2 (198 Views)

# Re: Insert circles Lisp

01-24-2013 11:00 AM in reply to: pzkmf

pzkmf wrote:

Am trying to put up a lisp routine to plot a couple a circles along the circumference of the cylinder(when its is develpoed flat). But the routine fails:

(defun c:cir ()
(setq rad (getreal "\nDiameter of the holes: "))
(setq dia (getreal "\nCylinder diameter: "))
(setq numb (getint "\nHoles needed: "))
(setq pt (getpoint "\nCircle centre point : "))
(setq pie 3.142)
(setq dist (/ *(pie dia) num)))
(setq counter 0)
(while (< counter numb)
(setq pt (polar pt 0 dist))
(setq counter (+ 1 counter)))

Some corrections I would suggest, and some simplifications....  There is already a symbol pi in AutoLISP that you can use directly.  You can combine multiple settings of variables in one (setq) function.  If you use (getdist) instead of (getreal), the User has the choice to specify the distance by either typing something [including in Architectural or Engineering or Fractional units, not limited to decimal units] or picking points on-screen.  Untested:

(defun c:cir ()
(setq

; [or if Diameter, call it that, and divide it in half in Circle command]

dia (getdist "\nCylinder diameter: ")
numb (getint "\nHoles needed: ")
pt (getpoint "\nCircle centre point : "); should this ask for something else?

; The centre is not relevant after the cylinder has been developed flat.

; Ask something about the location of the first hole in the flattened surface?
; (setq pie 3.142) not needed
dist (/ (* pi dia) numb); had * outside parentheses; missing the 'b'

counter 0

); end setq
(while (< counter numb)
(setq

pt (polar pt 0 dist)
counter (1+ counter); (+ 1 counter) is OK, but the (1+) function saves a whole character!

); end setq

); end while

); end defun missing

Kent Cooper
Post to the Community