Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Insert circles Lisp

1 REPLY 1
Reply
Message 1 of 2
pzkmf
370 Views, 1 Reply

Insert circles Lisp

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)))

1 REPLY 1
Message 2 of 2
Kent1Cooper
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)
(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

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost