Real-looking spirals can only be done with ACAD 2007 new features. With
previous versions you can do round threads. The problem before Acad 2007 was
that the shape to serve as a thread would spin about itself while being
twisted up the spiral. If you want a lisp that does a 3D spiral, just give a
shout and I'll post one.
Dr Fleau
I just re-read myself and I don't find myself very clear.
A 3D spiral can be done with pre-2007 ACAD, only it will be a single
polyline. To create realistic threads, you need Inventor or ACAD 2007.
I have a lisp that does a 3D pline spiral, if anyone needs one.
Dr Fleau
Here you go..
Copyright and everything...
;;; A.Dudek
;;; 3DSPIRAL.LSP
;;; Copyright (C) 1993 by Autodesk, Inc.
;;;
;;; Permission to use, copy, modify, and distribute this software
;;; for any purpose and without fee is hereby granted, provided
;;; that the above copyright notice appears in all copies and that
;;; both that copyright notice and this permission notice appear in
;;; all supporting documentation.
;;;
;;; THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED
;;; WARRANTY. ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR
;;; PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.
;;;
;;; DESCRIPTION
;;;
;;; 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", "3dspiral" or the following:
;;; (cspiral <# rotations> <base point> <horiz growth per rotation>
;;; <points per circle> <start radius>
;;; <vert growth per rotation>).
;;;
;;;
;;; Revision 3/9/95 Anthony Dudek
;;; Fixed problem of not drawing a full 360 degree helix when using only one
;;; rotation of 3dpolyline
;;;
(defun myerror (s) ; If an error (such as CTRL-C) occurs while this
command is active...
(if (/= s "Function cancelled")
(princ (strcat "\nError: " s))
)
(setvar "cmdecho" ocmd) ; Restore saved modes
(setvar "blipmode" oblp)
(setq *error* olderr) ; Restore old *error* handler
(princ)
)
(defun cspiral (ntimes bpoint hfac lppass strad vfac /
ang dist tp ainc dhinc dvinc circle
dv
)
(setvar "blipmode" 0) ; turn blipmode off
(setvar "cmdecho" 0) ; turn cmdecho off
(setq circle (* 3.141596235 2))
(setq ainc (/ circle lppass))
(setq dhinc (/ hfac lppass))
(if vfac
(setq dvinc (/ vfac lppass))
)
(setq ang 0.0)
(if vfac
(setq dist strad
dv 0.0
)
(setq dist 0.0)
)
(if vfac
(command "_3dpoly") ; start spiral ...
(command "_pline" bpoint) ; start spiral from base point and...
)
(repeat ntimes
;;;
;;; section of revised code
(if (= ntimes 1) ; if the number of
; rotations is 1
(repeat (1+ lppass) ; then calculate points
; one extra time to allow
; for the missing polyline segment at the end of
; the rotation
(setq tp (polar bpoint
(setq ang (+ ang ainc))
(setq dist (+ dist dhinc))
)
)
(if vfac
(setq tp (list (car tp) (cadr tp) (+ dv (caddr tp)))
dv (+ dv dvinc)
)
)
(command tp) ; continue to the next point...
) ; close inner repeat
;;;
; otherwise
(repeat lppass
(setq tp (polar bpoint
(setq ang (+ ang ainc))
(setq dist (+ dist dhinc))
)
)
(if vfac
(setq tp (list (car tp) (cadr tp) (+ dv (caddr tp)))
dv (+ dv dvinc)
)
)
(command tp) ; continue to the next point...
) ; close inner repeat
) ; close if
) ; close main repeat
(command "") ; until done.
(princ)
) ; close defun
;;;
;;; Interactive spiral generation
;;;
(defun C:SPIRAL (/ olderr ocmd oblp nt bp cf lp)
(command ".undo" "group")
(setq olderr *error**error* myerror
)
(setq ocmd (getvar "cmdecho"))
(setq oblp (getvar "blipmode"))
(setvar "cmdecho" 0)
(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 nil nil)
(setvar "cmdecho" ocmd)
(setvar "blipmode" oblp)
(setq *error* olderr) ; Restore old *error* handler
(princ)
(command ".undo" "end")
)
;;;
;;; Interactive spiral generation
;;;
(defun C:3DSPIRAL (/ olderr ocmd oblp nt bp hg vg sr lp)
(command ".undo" "group")
(setq olderr *error**error* myerror
)
(setq osn (getvar "OSMODE"))
(setvar "OSMODE" 0)
(setq ocmd (getvar "cmdecho"))
(setq oblp (getvar "blipmode"))
(setvar "cmdecho" 0)
(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 7) ; sr must not be zero, neg, or null
(setq sr (getdist bp "\nStarting radius: "))
(initget 1) ; cf must not be zero, or null
(setq hg (getdist "\nHorizontal growth per rotation: "))
(initget 3) ; cf must not be zero, or null
(setq vg (getdist "\nVertical growth 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 hg lp sr vg)
(command "_CIRCLE" bp (* 7 sr))
(setvar "cmdecho" ocmd)
(setvar "blipmode" oblp)
(setq *error* olderr) ; Restore old *error* handler
(princ)
(command ".undo" "end")
(setvar "OSMODE" osn)
)
(defun C:3s ()
(C:3dspiral)
)
;;;
(princ "\t3DSPIRAL.lsp loaded")
(princ)
Dr Fleau aka Pierre
Here ya go. I haven't run it yet tho. Just grabbed it the other
day....................
Dan
Here you go..
Copyright and everything...
;;; A.Dudek
;;; 3DSPIRAL.LSP
;;; Copyright (C) 1993 by Autodesk, Inc.
;;;
;;; Permission to use, copy, modify, and distribute this software
;;; for any purpose and without fee is hereby granted, provided
;;; that the above copyright notice appears in all copies and that
;;; both that copyright notice and this permission notice appear in
;;; all supporting documentation.
;;;
;;; THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED
;;; WARRANTY. ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR
;;; PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.
;;;
;;; DESCRIPTION
;;;
;;; 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", "3dspiral" or the following:
;;; (cspiral <# rotations> <base point> <horiz growth per rotation>
;;; <points per circle> <start radius>
;;; <vert growth per rotation>).
;;;
;;;
;;; Revision 3/9/95 Anthony Dudek
;;; Fixed problem of not drawing a full 360 degree helix when using only one
;;; rotation of 3dpolyline
;;;
(defun myerror (s) ; If an error (such as CTRL-C) occurs while this
command is active...
(if (/= s "Function cancelled")
(princ (strcat "\nError: " s))
)
(setvar "cmdecho" ocmd) ; Restore saved modes
(setvar "blipmode" oblp)
(setq *error* olderr) ; Restore old *error* handler
(princ)
)
(defun cspiral (ntimes bpoint hfac lppass strad vfac /
ang dist tp ainc dhinc dvinc circle
dv
)
(setvar "blipmode" 0) ; turn blipmode off
(setvar "cmdecho" 0) ; turn cmdecho off
(setq circle (* 3.141596235 2))
(setq ainc (/ circle lppass))
(setq dhinc (/ hfac lppass))
(if vfac
(setq dvinc (/ vfac lppass))
)
(setq ang 0.0)
(if vfac
(setq dist strad
dv 0.0
)
(setq dist 0.0)
)
(if vfac
(command "_3dpoly") ; start spiral ...
(command "_pline" bpoint) ; start spiral from base point and...
)
(repeat ntimes
;;;
;;; section of revised code
(if (= ntimes 1) ; if the number of
; rotations is 1
(repeat (1+ lppass) ; then calculate points
; one extra time to allow
; for the missing polyline segment at the end of
; the rotation
(setq tp (polar bpoint
(setq ang (+ ang ainc))
(setq dist (+ dist dhinc))
)
)
(if vfac
(setq tp (list (car tp) (cadr tp) (+ dv (caddr tp)))
dv (+ dv dvinc)
)
)
(command tp) ; continue to the next point...
) ; close inner repeat
;;;
; otherwise
(repeat lppass
(setq tp (polar bpoint
(setq ang (+ ang ainc))
(setq dist (+ dist dhinc))
)
)
(if vfac
(setq tp (list (car tp) (cadr tp) (+ dv (caddr tp)))
dv (+ dv dvinc)
)
)
(command tp) ; continue to the next point...
) ; close inner repeat
) ; close if
) ; close main repeat
(command "") ; until done.
(princ)
) ; close defun
;;;
;;; Interactive spiral generation
;;;
(defun C:SPIRAL (/ olderr ocmd oblp nt bp cf lp)
(command ".undo" "group")
(setq olderr *error**error* myerror
)
(setq ocmd (getvar "cmdecho"))
(setq oblp (getvar "blipmode"))
(setvar "cmdecho" 0)
(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 nil nil)
(setvar "cmdecho" ocmd)
(setvar "blipmode" oblp)
(setq *error* olderr) ; Restore old *error* handler
(princ)
(command ".undo" "end")
)
;;;
;;; Interactive spiral generation
;;;
(defun C:3DSPIRAL (/ olderr ocmd oblp nt bp hg vg sr lp)
(command ".undo" "group")
(setq olderr *error**error* myerror
)
(setq osn (getvar "OSMODE"))
(setvar "OSMODE" 0)
(setq ocmd (getvar "cmdecho"))
(setq oblp (getvar "blipmode"))
(setvar "cmdecho" 0)
(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 7) ; sr must not be zero, neg, or null
(setq sr (getdist bp "\nStarting radius: "))
(initget 1) ; cf must not be zero, or null
(setq hg (getdist "\nHorizontal growth per rotation: "))
(initget 3) ; cf must not be zero, or null
(setq vg (getdist "\nVertical growth 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 hg lp sr vg)
(command "_CIRCLE" bp (* 7 sr))
(setvar "cmdecho" ocmd)
(setvar "blipmode" oblp)
(setq *error* olderr) ; Restore old *error* handler
(princ)
(command ".undo" "end")
(setvar "OSMODE" osn)
)
(defun C:3s ()
(C:3dspiral)
)
;;;
(princ "\t3DSPIRAL.lsp loaded")
(princ)
Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here.
All logos and trade names are the property of their respective owners.