And more.

This version uses target depth and depth increment, and also does a complete circuit (minus one segment) at the top and bottom depths in order to finish out the contour.

LLoyd

1)Updated to fix target depth rounding, and to reduce the line increments in the top and bottom circuits...

-----------------------------------------------

'//////////////////////////////////////////////////////////////////////////////

'

' Conic_helical_pocket.vbs

' CamBam vbscript

' by AMDlloydsp, with credits to 10 Bulls for the idea from "Boingy"

' and added features requested by GraphicsMan

'

' based upon "conic helix.vbs". This routine differs by using a target

' depth and depth increment, and does one complete circuit at the starting

' and ending depths, in order to finish the contour.

'

dim turns as single

dim top_diameter as single

dim bottom_diameter as single

dim depth_increment as single

dim strAnswer as string

dim direction as single

dim smooth as single

dim target_depth as single

dim test_string as string

function MakeConicHelix as polyline

dim start as single = 0 ' in radians

dim finish as single = turns*2*pi '30*pi ' in radians

dim steps as single = turns*smooth ' number of steps

dim radius as single = top_diameter/2

dim startz as single = 0

dim endz as single = -1*depth_increment*turns

dim radius_step as single = (bottom_diameter-top_diameter)/(steps*2)

dim x as single = 0

dim y as single = 0

dim z as single = startz

dim th as single = start

dim dt as single = (finish-start)/steps*direction

dim dz as single = (endz-startz)/steps

'// Get the drawing ready to draw

dim p as Polyline = new Polyline

' start by doing one full turn without any depth increment

for i as short = 0 to smooth-1

x = radius * math.cos(th)

y = radius * math.sin(th)

p.Add(x,y,z)

th = th + dt

next i

' now make loops with depth increment per loop

for i as short = 0 to steps-1

if z+dz < target_depth

z=target_depth

else

z = z + dz

end if

x = radius * math.cos(th)

y = radius * math.sin(th)

p.Add(x,y,z)

radius=radius+radius_step

th = th + dt

if z=target_depth then exit for

next i

' finally, make one loop at depth to finish out the bottom

for i as short = 0 to smooth-1

x = radius * math.cos(th)

y = radius * math.sin(th)

p.Add(x,y,z)

th = th + dt

next i

MakeConicHelix = p

end function

sub main

top_diameter=val(Inputbox ("Top diameter? "))

bottom_diameter=val(Inputbox ("Bottom diameter (must be <= top diameter, or hole will be cylindrical)? "))

depth_loop:

target_depth=val(Inputbox("Target depth (must be negative)"))

if target_depth>=0

goto depth_loop

end if

depth_increment=Math.Abs(val(Inputbox ("Depth increment")))

turns=Math.Abs(target_depth/depth_increment)

direction=val(Inputbox("Direction to turn -- -1=CCW, 1=CW"))

direction=direction*-1

smooth=val(Inputbox("Smoothing factor (number of segments per turn) recommended 100 per turn as a compromise."))

'test_string=string.format("Top={0}, Bottom={1}, Target={2}, Incr={3}, turns={4}",top_diameter,bottom_diameter,target_depth,depth_increment,turns)

'MsgBox(test_string)

dim p as polyline = MakeConicHelix()

doc.add(p)

end sub