AutoLISP: Making a PolyLine Spiral

I found this thinking that someday I would need it. So now I share it with you in case you too need it. After all without it, how else can you easily make a spiral in AutoCAD?

This routine is from 1985 and shows that old AutoLISP routines still work after a 26 years.

Here’s how it works:

  • SPIRAL <enter> to start
  • Specify center point of the spiral
  • Specify # of rotations
  • Specify the spacing between the rotations
  • Specify how many polyline segments in each rotation (the more segments, the rounder the polyline will appear)

; This is a programming example.


; Designed and implemented by Kelvin R. Throop in January 1985


; This program constructs a spiral. It can be loaded and called

; by typing either "spiral" or the following:

; (cspiral <# rotations> <base point> <growth per rotation>

; <points per circle>).


(defun cspiral (ntimes bpoint cfac lppass / ang dist tp ainc dinc circle bs cs)

(setq cs (getvar "cmdecho")) ; save old cmdecho and blipmode

(setq bs (getvar "blipmode"))

(setvar "blipmode" 0) ; turn blipmode off

(setvar "cmdecho" 0) ; turn cmdecho off

(setq circle (* 3.141596235 2))

(setq ainc (/ circle lppass))

(setq dinc (/ cfac lppass))

(setq ang 0.0)

(setq dist 0.0)

(command "pline" bpoint) ; start spiral from base point and...

(repeat ntimes

(repeat lppass

(setq tp (polar bpoint (setq ang (+ ang ainc))

(setq dist (+ dist dinc))))

(command tp) ; continue to the next point...



(command) ; until done.

(setvar "blipmode" bs) ; restore saved blipmode

(setvar "cmdecho" cs) ; restore saved cmdecho




; Interactive spiral generation


(defun C:SPIRAL ( / nt bp cf lp)

(initget 1) ; bp must not be null

(setq bp (getpoint "\nCenter point: "))

(initget 7) ; nt must not be zero, neg, or null

(setq nt (getint "\nNumber of rotations: "))

(initget 3) ; cf must not be zero, or null

(setq cf (getdist "\nGrowth per rotation: "))

(initget 6) ; lp must not be zero or neg

(setq lp (getint "\nPoints per rotation <30>: "))

(cond ((null lp) (setq lp 30)))

(cspiral nt bp cf lp)



About AutoCAD Tips

This blog serves as a knowledge base for myself (and anyone else) so that I can reference tips & tricks that I have learned and also refer others to it as well. I hope that this blog helps you learn at least one tip to make your drafting/design experience better.
This entry was posted in AutoLISP, Polylines, TIPS. Bookmark the permalink.

2 Responses to AutoLISP: Making a PolyLine Spiral

  1. Marcos Palomo says:

    Hi Greg,

    I am having a terrible time with Autocad (using it for a CNC wood machine), and have stumbled on your blog. I have yet to successfully use your autolisp stuff, because my autocad is in Spanish (I’m in the process of getting it in English), but there is a world of useful knowledge on your blog, thanks a lot for the time you put into this, autocad drives me mental, and anyone who bothers to help deserves recognition!

    • AutoCAD Tips says:

      Thank you so much for your comments. I know your frustration. I think that AutoCAD gets moody sometimes and likes to turn on you. But at least you are searching online and looking for help. One helpful tip I would suggest is to dig deeper into AutoCAD and try to understand how/why it thinks the way it does, that way when it turns on you, you might understand it better.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s