Spiral in 3D

Discussion in 'AutoCAD' started by StarMan, Jul 30, 2007.

  1. StarMan

    StarMan Guest

    Anyone know how to generate a spiral in 3D in ACAD?

    I want to model a spring. I figure the first step will be generating a 3D
    polyline or spline as a path.
     
    StarMan, Jul 30, 2007
    #1
  2. StarMan

    hpspt Guest

    It's very simple in 2007 or 2008.
    Very difficult with 2006 or before.
    Which version do you use?
     
    hpspt, Jul 30, 2007
    #2
  3. StarMan

    StarMan Guest

    2000 :-(
     
    StarMan, Jul 30, 2007
    #3
  4. StarMan

    hpspt Guest

    With 2000, one way is to build a torus, cut ir in 4 equal parts. make a
    little rotation for parts 2 3 4, another one same angle) for parts 3 and 4
    and another one (same angle) for part 4 in such a way to get 1 turn spiral
    and copy as many times as necessary.
    Problem: it's not a real spiral...

    --
    hpspt
     
    hpspt, Jul 30, 2007
    #4
  5. StarMan

    The-trooper Guest

    The-trooper, Jul 30, 2007
    #5
  6. StarMan

    Dr Fleau Guest

    Hiya

    No sweat. Here's the routine, test it a few times to get the feel for
    it. I suggest you draw a circle first then pick the circle's center as
    a reference point as this routine does not give you one nor can you
    pick the center of the spring once created. I hope I made sense.

    Dr Fleau

    www.cadalyst.com Section: "Get the code"

    ;Tip1736b: 3DSPIRAL.LSP Create 3D spring

    ;;; 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
    ;;; Modified by Bill Zondlo 12/30/99 to be used with SOL_SPRING.LSP.
    ;;; This program now contains 3DSpiral.lsp only.
    ;;;
    --------------------------------------------------------------------------;

    (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
    (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...
    )
    )
    (command "") ; until done.
    (princ)
    )

    ;;;
    ;;; Interactive spiral generation
    ;;;

    (defun C:3DSPIRAL (/ olderr ocmd oblp nt bp hg vg sr lp)
    (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 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)
    (setvar "cmdecho" ocmd)
    (setvar "blipmode" oblp)
    (setq *error* olderr) ; Restore old *error* handler
    (princ)

    )
    ;;;
    --------------------------------------------------------------------------;
    (princ "\n\tC:3DSPIRAL loaded. ")
    (princ)
     
    Dr Fleau, Aug 6, 2007
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.