Visual LISP, AutoLISP and General Customization

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

Insert circles Lisp

193 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)
(command "_circle" pt rad "")
(setq pt (polar pt 0 dist))
(setq counter (+ 1 counter)))

*Expert Elite*
Kent1Cooper
Posts: 5,237
Registered: ‎09-13-2004
Message 2 of 2 (183 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)
(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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community