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)
(command "_circle" pt rad "")
(setq pt (polar pt 0 dist))
(setq counter (+ 1 counter)))
@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)
(command "_circle" pt rad "")
(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
rad (getdist "\nRadius of the holes: "); not Diameter
; [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)
(command "_circle" pt rad); "" was extraneous [giving radius ends command]
(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