TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Keith™ on July 12, 2004, 02:20:39 PM
-
Ok, I remember some time ago a thread (probably over at the now defunct site) about a proggie that would draw 3dSolid threads.. If anyone has it or something that is comparable I could use it....
-
Keith....I found this for starters....know I got sumpin better......
;;; 3DSPIRAL.LSP
; Copyright (C) 1992 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>).
;;;
;;; --------------------------------------------------------------------------;
(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:SPIRAL (/ olderr ocmd oblp nt bp cf 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 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)
)
;;;
;;; 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:SPIRAL and C:3DSPIRAL loaded. ")
(princ)
I'll keep lookin'.....
-
.....or this.......
; HELIX.LSP 8/89 Tony Tanzillo.
;Thanx to Andy Anderson for reviving this routine.....
; Draws 3D helical springs and coils of varying width.
;
; Generic front end, no validation of user input is done, and
; and no error handler is included.
;
(defun C:HELIX ( / cp od wi sa pt rt)
(cond
( (and (setq cp (getpoint "\nCenter point: "))
(setq ra (getdist cp "\nOutside radius: "))
(setq wi (getdist "\nCoil width: "))
(setq sa (getangle cp "\nStarting angle: "))
(setq pt (getdist "\nPitch: "))
(setq rt (getreal "\nNumber of rotations: ")))
(princ "\nGenerating helix...")
(helix cp (* 2.0 ra) wi sa pt rt)))
(princ)
)
; Returns delta Z offset of a 2D or 3D point in the current UCS
(defun delta_z (pt z)
(list (car pt)
(cadr pt)
(cond ( (caddr pt) (+ (caddr pt) z)) (t z))))
; (helix )
;
; Back end for C:HELIX
;
; Note: SURFTAB1 controls resolution (number of segments/rotation)
(defun helix ( cp od wi sang pitch rot /
orad irad segs s_ang s_pitch bp iang w bm)
(setq segs (getvar "surftab1") ; SURFTAB1 controls resolution
s_ang (/ (* 2.0 pi) segs) ; included angle of segment
s_pitch (/ pitch segs) ; segment pitch (z offset)
iang (- sang s_ang) ; segment angle
bp (delta_z cp (- s_pitch)) ; segment pitch
orad (/ od 2.0) ; outer radius
irad (- orad wi)) ; inner radius
(setvar "cmdecho" 0)
(setq bm (getvar "blipmode"))
(setvar "blipmode" 0)
(cond ( (setq w (> wi 0.0)) ; if helix width > 0,
(command "3DMESH" ; then start a 3DMESH
(fix (1+ (* segs rot))) 2)) ; M = 1 + segements * rotations
; N = 2 edges of the flat coil
(t (command "3DPOLY"))) ; otherwise, start 3D polyline
(repeat (fix (1+ (* segs rot))) ; and go for it
(command
(polar
(setq bp (delta_z bp s_pitch)) ; increment pitch
(setq iang (+ iang s_ang)) ; increment angle
orad )) ; outer radius
(cond (w (command (polar bp iang irad)))) ; if helix has width, then
) ; specify inner edge.
(cond ((not w) (command ""))) ; Stop if drawing a 3DPLINE.
(setvar "blipmode" bm)
)
......still diggin'.....[/quote]
-
These are great.. I will see if they will do what I need in the AM... I may be able to modify them to produce a 3dSolid on the path generated by a 3dpoly, but I am not holding my breath
-
The one i remembered had to do with Helix.lsp but ended up pointing here.
http://cadtutorforum.net/forum/viewtopic.php?t=477
-
Just to satisfy my curiosity, Keith. why are you trying to draw threads? The couple of feeble attempts I made some years ago were not the greatest, except in file size. The word "HUGE" comes to mind. with over 300 nuts, bolts and screws in a typ. assy, it was *really* counter-productive....
-
Patent drawings... they are very particular in the view, thread pitch, depth.. etc... it must be shown and be to scale, submitted in ACIS Solid format ... I was thinking of doing it in TurboCAD because it is part of their mechanical package, but I don't want to do it if I don't have to.
-
That might end up being your best bet. do you have access to a parametric...Inventor or SWX?
They handle this kind of solids geometry better than ACAD.....
-
nope sure dont.... and I would have to purchase TurboCAD to do it too... I think I may be able to handle it with the proggies above.. we'll see