Helix

This routine draws a 3D Polyline in the form of a helix and an axis line. The user must specify the base radius, top radius, height, number of turns and the number of line segments per turn. The more line segments used, the smoother the curve will appear (default 20).

The routine creates a helix in a clockwise direction (sense). If you would like to create counter-clockwise helixes, change the second line of code from (setq spin -1) to (setq spin 1).

Code:
;   draw a helix 
;   mfuccaro@hotmail.com 
;  ----- November.2002 ----- 
;
(defun c:helix() 
  (setq spin -1); -1=CW, 1=CCW 
  (setq ri (getreal "Base radius: ") rf (getreal "Top radius: ")) 
  (initget (+ 1 4)) 
  (setq h (getreal "Height: ")) 
  (initget (+ 1 2 4)) 
  (setq tu (getreal "Number of turns: ")) 
  (setq segs (getint "Number of segments per turn <20>: ")); more=smoother 
  (if (= segs nil)(setq segs 20))
  (setq old (getvar "osmode")) 
  (setvar "cmdecho" 0)  
  (setq fi1 (/ (* 2 PI) segs) i 0) 
  (setq points (fix (* tu segs)) 
   h1 (/ h points) r1 (/ (- rf ri) points) 
   s (getpoint "Center of base: ") 
   end (list (car s) (cadr s) (+ h (caddr s)))) 
  (setvar "osmode" 0 ) 
  (command "line" s end "") 
  (command "chprop" "l" "" "c" 1 "") 
  (command "3dpoly") 
  (setq i 0) 
  (repeat (1+ points) 
    (setq fi (* i fi1) h (* i h1) r (+ ri (* i r1))) 
    (setq x (* r (cos fi)) y (* spin r (sin fi))) 
    (command (list (+ (car s) x) (+ (cadr s) y) (+ (caddr s) h))) 
    (setq i (1+ i))) 
  (command "") 
  (setvar "osmode" old))
(princ "\nRoutine loaded. Type HELIX at the command prompt.") 
(princ)
Download helix.lsp 1.13KB

The result of this routine is shown below:



Once the helix has been drawn, you could use it as an extrusion path.

See the original topic for more details.