Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Spiral needed with a twist

42 REPLIES 42
Reply
Message 1 of 43
Anonymous
1762 Views, 42 Replies

Spiral needed with a twist

Typ., all of the spiral lisp I've found offset the growth ring the same distance, ex. first ring 4m, next 4m , next 4 m, etc.

Can anyone make a slight adjustment to an existing or new lisp/VBA program to add a plus factor number such as 1 to the previous spiral ring? The plus factor number is the twist. Example, if the radius of the first ring intersection point is 4 meters, add plus 1 factor to each subsequent ring making the next ring it 5 meters, next is 6 meters, next is 7 meters, etc.

I need to be able to provide geometric input such as start point and radius of first ring. It would even better if I input my own offset factor. Instead of inputting a plus 1 for each ring, I might try 1.25, 1.50, 1.75 or 2, until I got the shape I wanted. If not, it could be identified in the lisp where I could edit the plus factor number.

I hope my request is clear. Thank you in advance.
42 REPLIES 42
Message 2 of 43
Anonymous
in reply to: Anonymous

[If you can post an existing routine you've found that does it the "wrong"
way, it might be easier to adjust that to do it the "right" way than to come
up with an entire routine, or to duplicate the searching you've apparently
already done.]
--
Kent Cooper


wrote...
Typ., all of the spiral lisp I've found offset the growth ring the same
distance, ex. first ring 4m, next 4m , next 4 m, etc.

Can anyone make a slight adjustment to an existing or new lisp/VBA program
to add a plus factor number such as 1 to the previous spiral ring? The plus
factor number is the twist. Example, if the radius of the first ring
intersection point is 4 meters, add plus 1 factor to each subsequent ring
making the next ring it 5 meters, next is 6 meters, next is 7 meters, etc.

I need to be able to provide geometric input such as start point and radius
of first ring. It would even better if I input my own offset factor. Instead
of inputting a plus 1 for each ring, I might try 1.25, 1.50, 1.75 or 2,
until I got the shape I wanted. If not, it could be identified in the lisp
where I could edit the plus factor number.

I hope my request is clear. Thank you in advance.
Message 3 of 43
Anonymous
in reply to: Anonymous

Attached is a routine i found that I have made a few adjustments. Let me know if this one can be reworked for my request.

Thanks
Message 4 of 43
Anonymous
in reply to: Anonymous

[I think I might have had something to do with that routine (I certainly
contributed to a thread about something very similar, some time back),
though parts of it are not the way I would do it, at least if I were to do
it now.]

If you want to do exactly what that one does, but specify the difference in
radius from one time around to the next, then you would not ask for the
number of Turns (the 'tu' variable). Instead, you would ask for the
difference in radius, and divide that by the number of segments per turn,
and increment the radius by that amount from one point to the next. Other
aspects would be calculated differently, too, since the criteria would be
different -- especially the figuring of when to stop, since the end would be
determined by reaching the ending radius, not by how many times it had gone
around.

That one makes multiple conical 3D spiral approximations (out of
straight-line segments). It appears you "commented out" the 3DPOLY line and
put in the regular PLINE one, which raises the question whether you want it
to lie flat -- that would simplify the whole thing a lot. And you would ask
for something like "starting" and "ending" radii, rather than "base" and
"top."

Seeing that you commented out the array near the end, do you only want one
spiral? (You didn't comment out the prompt for the number of spirals.)

I also assume you commented out the extrusion radius prompt, and the drawing
and extruding of the circle near the end. If you don't want that part of
it, you would also be able to eliminate the UCS operation near the end,
which is only there to draw the circle in the right orientation for
extruding along the spiral.

Also, if you use a 2D Polyline instead of 3D, you have the option of
approximating the spiral shape more closely by using arc segments instead of
line segments.

So, the most important clarifications in my mind are:
Do you want a flat spiral or a conical 3D spiral?
Do you want one, or more than one?
Do you want curves or straight segments?
[There are various other things that could be specified differently, but
start with those....]
--
Kent Cooper


wrote...
Attached is a routine i found that I have made a few adjustments. Let me
know if this one can be reworked for my request.

Thanks
Message 5 of 43
Anonymous
in reply to: Anonymous

Do you want a flat spiral or a conical 3D spiral? I want a flat spiral.

Do you want one, or more than one? I want just one.

Do you want curves or straight segments? I want curved segments.

No, I don't want want extrudsion radius.

Those are all great observations and questions. I look forward to seeing what you come up with.
Message 6 of 43
Anonymous
in reply to: Anonymous

Hi Kent, do you have any news for me?
Message 7 of 43
Anonymous
in reply to: Anonymous

see it , it have a SPIRAL function , it make what you need , just put as big number as
(setq lp (getint "\nPoints per rotation <30>: "))

and you will get it.
Message 8 of 43
Anonymous
in reply to: Anonymous

Thanks Devitg. I'm at home in the moment, I'll take look at this one when I'm the office later today.

I'm looking forward to seeing the routine I modified for Kent. I studied it over the weekend to decipher it's functionality.
Message 9 of 43
Anonymous
in reply to: Anonymous

[I'm thinking about it, and have something started, but not finished.
Unfortunately, I'm not likely to get any further with it today.]
--
Kent Cooper


wrote...
Hi Kent, do you have any news for me?
Message 10 of 43
Anonymous
in reply to: Anonymous

Devitg, I was not able to use your routine. I need a flat spiral.
Message 11 of 43
Anonymous
in reply to: Anonymous

Well, since I may not get to playing with this further for a little while,
here's where I'm headed, but it doesn't work yet. Maybe someone else can
figure out what's wrong with the (while) part. I hope it's apparent what
it's trying to do, and that the things it asks for from the user are what
you want.

(defun C:SPIEQ ()
(if (< (getvar "osmode") 16384)
(progn
(setq osm (getvar "osmode"))
(setvar "osmode" (+ (getvar "osmode") 16384))
); progn
); if
(setq
ctr (getpoint "Center Point of Spiral: ")
rad1 (getdist "Starting Radius: ")
rad2 (getdist "Ending Radius: ")
span (- rad2 rad1)
space (getdist "Spacing Between Turns: ")
radinc (/ space 8.0)
leftover (rem span radinc)
direc 0
segment 1
rad (+ rad1 radinc)
); setq
(command "PLINE" (polar ctr 0 rad1)
"A" "S" (polar ctr (/ pi 8) (+ rad1 (/ radinc 2)))
(polar ctr (/ pi 4) rad)
(while (<= (+ rad radinc) rad2)
(setq
segment (1+ segment)
rad (+ rad radinc)
pt (polar ctr (* segment (/ pi 4)) rad)
); setq
); while --------------------------------something doesn't work; returns
final point only to Pline, not intermediate ones
(if (/= leftover 0.0)
(polar ctr (* (+ segment leftover) (/ pi 4)) rad2)
); if
); command
(if (/= osm nil)
(setvar "osmode" osm)
); if
); defun

--
Kent Cooper


wrote in message news:5429533@discussion.autodesk.com...
Hi Kent, do you have any news for me?
Message 12 of 43
Anonymous
in reply to: Anonymous

Thanks Kent. I appreciate the time you've spent on this. Hopefully, someone else will be able to assist in complete the routine and solving the problem.
Message 13 of 43
Anonymous
in reply to: Anonymous

Hi . please use this part
(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
;; wfr start 3D spiral from X axis
;; the following "progn" replaces (command "3dpoly")
(progn
(setq stpt (list (+ (car bpoint) strad) (cadr bpoint) (caddr bpoint)))
(command "3dpoly" stpt) ; start spiral ...
(setq dv (+ dv dvinc)) ; next point gets a Z increment
)
(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 2D 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)

)
Message 14 of 43
Anonymous
in reply to: Anonymous

Bump
Message 15 of 43
Anonymous
in reply to: Anonymous

Is there what you need?

Option Explicit

Sub SpiralTest()
Dim oPoly As AcadPolyline
Dim dblRad As Double
Dim dltAng As Double, incRad As Double, dltInc As Double
Dim iNum As Integer, iCnt As Integer, Counter As Integer
Dim centPt(2) As Double, varPt As Variant
Dim dblPts() As Double
Dim Pi As Double
Pi = Atn(1) * 4

dblRad = 5# ' starting radius
incRad = 1.25 ' step between threads
iCnt = 25 ' number of threads
iNum = 256 ' number of segments per rotation

dltAng = (Pi * 2) / iNum
dltInc = incRad / iNum
iNum = iCnt * iNum + 1

centPt(0) = 0#: centPt(1) = 0#: centPt(2) = 0#

ReDim Preserve dblPts(0 To iNum * 3 - 1) As Double
iCnt = 0: Counter = 0

Do While iCnt < iNum * 3 - 1

varPt = ThisDrawing.Utility.PolarPoint(centPt, dltAng * Counter, dblRad + (dltInc * Counter))
dblPts(iCnt) = varPt(0)
dblPts(iCnt + 1) = varPt(1)
dblPts(iCnt + 2) = varPt(2)
iCnt = iCnt + 3
Counter = Counter + 1

Loop

Set oPoly = ThisDrawing.ModelSpace.AddPolyline(dblPts)
oPoly.Update

End Sub

~'J'~
Message 16 of 43
Anonymous
in reply to: Anonymous

I'm having problems loading this routine. Could you please upload as a file and verify it does work. Thank you and for your assistance too.
Message 17 of 43
Anonymous
in reply to: Anonymous

Sorry, right now I have a got an urgent project
of HVAC systems for the cloister
I can to do the complete dvb project for
you with user form but later

You can go to VBA editor (Alt+f11) and
insert Module (menu Unsert->Module)
copy this code in the module
Then go to File->Export File and save this
module say as Spiral.bas in folder you need

In the menu Run->Run macro and see
what this will be draw

Frankly, I haven't have a time

Later

~'J'~
Message 18 of 43
Anonymous
in reply to: Anonymous

J, thanks for the additional info. I was able to load the routine. unfortunately, this did not meet my needs. the VBA created spirals with thread a consistently distance apart. I need for each thread to continuously increase with completed spiral. I see now that it was not clear as I had thought, so I'll elaborate.

Example, if the radius of the first ring intersection point is 4 meters, add plus 1 factor to each subsequent ring making the next ring it 5 meters, next is 7 meters, next is 10 meters, etc"

4 meters + 1 = 5 meters
5 meters + 1 + 1 = 7 meters
7 meters + 1 + 1 + 1 = 10 meters
10 meters + 1 + 1 + 1 + 1 = 14 meters
14 meters + 1 + 1 + 1 + 1 + 1 = 20 meters

Actually, it seems to accomplish this a factor or multiplier would have to be applied to each segment. I changed the number of segments to 30. I discovered each segment point's radius is consistently 0.04167 further from center than the next. To obtain what I am asking for, each segment point would continuously increase, moving it further from center. The chord of each segment is slightly longer. THAT"S IT! It's not based on the spiral getting accumulative wider, it's that each chord of a segment get longer. Maybe this will help you and other figure this out.

I bet Civil does this type of thing all of the time. Good luck with your submission and I look forward to hearing from you.
Message 19 of 43
Anonymous
in reply to: Anonymous

Oh, my bad
Now is all clear for me
Okay I'll try to solve it
in other words formula will be like this:

rad= initial rad + (number of thread - 1) * increment

~'J'~
Message 20 of 43
Anonymous
in reply to: Anonymous

That looks right to me.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report