Repost w/attachment: Drawing Springs

Repost w/attachment: Drawing Springs

Post by Chris Gelderma » Thu, 24 Apr 1997 04:00:00



The best I have found for drawing springs uses a lisp program called
SPIRAL.  First you use SPIRAL to create a 3d spiral. Next draw a circle
normal to the spiral.  Extrude the circle using the spiral as the path.

This works well for springs or other spiral shapes using with circular
cross sections.  For threads the triangle or thread shape rotates or
precesses as it is extruded along the path.  This makes it unuseable for
bolts or screws.

Below is the lisp program and an attachment.

;;;  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 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)
 (command ".undo" "end")
)
(defun C:3s ()
(C:3dspiral))
;;;
(princ "\n\tC:SPIRAL and C:3DSPIRAL loaded. ")
(princ "\n\tStart 3DSPIRAL command with 3S")
(princ)

begin 600 Spiral.lsp
<uuencoded_portion_removed>
69"!W:71H(#-3(BD-"BAP<FEN8RD-"EQT
`
end

 
 
 

Repost w/attachment: Drawing Springs

Post by Fabrizio Croc » Fri, 25 Apr 1997 04:00:00


<<rman wrote:

:The best I have found for drawing springs uses a lisp program called
 SPIRAL.  First you use SPIRAL to create a 3d spiral. Next draw a circle
 normal to the spiral.  Extrude the circle using the spiral as the path.

 This works well for springs or other spiral shapes using with circular
 cross sections.  For threads the triangle or thread shape rotates or
 precesses as it is extruded along the path.  This makes it unuseable for
 bolts or screws.

 Below is the lisp program and an attachment.

 ;;;  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 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)
  (command ".undo" "end")
 )
 (defun C:3s ()
 (C:3dspiral))
 ;;;
 (princ "\n\tC:SPIRAL and C:3DSPIRAL loaded. ")
 (princ "\n\tStart 3DSPIRAL command with 3S")
 (princ)

 begin 600 Spiral.lsp
 M.SL[("!!+D1U9&5K#0H[.SL@(#-$4U!)4D%,+DQ34 T*.SL[("!#;W!Y<FEG
 M:'0@*$,I(#$Y.3,@8GD@075T;V1E<VLL($EN8RX-"CL[.PT*.SL[("!097)M
 M:7-S:6]N('1O('5S92P@8V]P>2P@;6]D:69Y+"!A;F0@9&ES=')I8G5T92!T
 M:&ES('-O9G1W87)E( T*.SL[("!F;W(@86YY('!U<G!O<V4@86YD('=I=&AO
 M=70@9F5E(&ES(&AE<F5B>2!G<F%N=&5D+"!P<F]V:61E9" -"CL[.R @=&AA
 M="!T:&4@86)O=F4@8V]P>7)I9VAT(&YO=&EC92!A<'!E87)S(&EN(&%L;"!C
 M;W!I97,@86YD('1H870@#0H[.SL@(&)O=&@@=&AA="!C;W!Y<FEG:'0@;F]T
 M:6-E(&%N9"!T:&ES('!E<FUI<W-I;V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86,@
 M#0H@("AC;VUM86YD(")?,V1P;VQY(BD@(" @(" @"3L@<W1A<G0@<W!I<F%L
 M("XN+@T*(" H8V]M;6%N9" B7W!L:6YE(B!B<&]I;G0I(" @(" [('-T87)T
 M('-P:7)A;"!F<F]M(" @(" @(#MB87-E('!O:6YT(&%N9"XN+@T*("D-"B H
 M<F5P96%T(&YT:6UE<R -"CL[.PT*.SL[('-E8W1I;VX@;V8@<F5V:7-E9"!C
 M;V1E#0H-"B @*&EF("@](&YT:6UE<R Q*2 @(" @(" @(#L@:68@=&AE(&YU
 M;6)E<B!O9@T*"0D)"2 @.W)O=&%T:6]N<R!I<R Q#0H@(" @*')E<&5A=" H
 M,2L@;'!P87-S*2 @(" @(#L@=&AE;B!C86QC=6QA=&4@<&]I;G1S(#MO;F4@
 M97AT<F$@=&EM92!T;R!A;&QO=PT*(" @(" @(" @(" @(" @(" @(#L@9F]R
 M('1H92!M:7-S:6YG('!O;'EL:6YE('-E9VUE;G0@870@=&AE(&5N9"!O9@T*
 M(" @(" @(" @(" @(" @(" @(#L@=&AE(')O=&%T:6]N#0H@(" @("AS971Q
 M('1P("AP;VQA<B!B<&]I;G0@*'-E='$@86YG("@K(&%N9R!A:6YC*2D-"B @
 M(" @(" @(" @(" @(" H<V5T<2!D:7-T("@K(&1I<W0@9&AI;F,I*0T*(" @
 M(" @(" @*0T*(" @(" I#0H@(" @("AI9B!V9F%C#0H@(" @(" @*'-E='$@
 M=' @*&QI<W0@*&-A<B!T<"D@*&-A9'(@=' I("@K(&1V("AC861D<B!T<"DI
 M*0T*(" @(" @(" @(&1V("@K(&1V(&1V:6YC*0T*(" @(" @("D-"B @(" @
 M*0T*(" @(" H8V]M;6%N9"!T<"D@(" @(" @(" @.R!C;VYT:6YU92!T;R!T
 M:&4@;F5X="!P;VEN="XN+@T*(" @("D[8VQO<V4@:6YN97(@<F5P96%T#0H[
 M.SL-"CMO=&AE<G=I<V4@(" @(" -"B @("AR97!E870@;'!P87-S( T*(" @
 M(" H<V5T<2!T<" H<&]L87(@8G!O:6YT("AS971Q(&%N9R H*R!A;F<@86EN
 M8RDI#0H@(" @(" @(" @(" @(" @*'-E='$@9&ES=" H*R!D:7-T(&1H:6YC
 M*2D-"B @(" @(" @(" @(" @(" @*0T*(" @(" I#0H@(" @("AI9B!V9F%C
 M#0H@(" @(" H<V5T<2!T<" H;&ES=" H8V%R('1P*2 H8V%D<B!T<"D@*"L@
...

read more »

 
 
 

1. Changing a dim's attachment in a drawing

Is there a way to change which hole/radius/etc a dimension points to
in  drawing?

Example: I have more than one edge picked for a radius (all the same
size tho). When I import dimensions, SW invariably picks the most
inconvienent radius to attach the dimension to. The other radius has a
lot more space around it and would make the drawing much less cluttered.

Is there a way to change which radius the dimension points to?

--john

p.s. funny thing is, if I insert _another_ (temporary)front view and
import dims into _that_ view, when I move dims to the original front
view (the one I'll actually use) the dimension sometimes switches to
the other radius.

Sent via Deja.com
http://www.deja.com/

2. A new website for PC natural language programs.

3. Random general purpose 3D drawing tools [LOFT.LSP] <repost>

4. client for Microsoft Networks (Win CE?)

5. Drawing springs?

6. online slides for C++ OOP course

7. how to draw a spiral and spring?

8. Soliloquy on Llama Dung

9. Drawing a spring

10. Help required on how to draw a spring in 3d in R14

11. Drawing Springs

12. Drawing a Spring in 3D

13. Spring drawing