Author Topic: New conic_helical_pocket.vbs with depth and depth increment  (Read 8312 times)

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 8331
    • View Profile
New conic_helical_pocket.vbs with depth and depth increment
« on: December 21, 2014, 23:54:58 pm »
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
« Last Edit: December 22, 2014, 00:33:32 am by lloydsp »
"Pyro for Fun and Profit for More Than Fifty Years"

Offline GraphicMan

  • Droid
  • **
  • Posts: 80
    • View Profile
Re: New conic_helical_pocket.vbs with depth and depth increment
« Reply #1 on: December 22, 2014, 00:16:54 am »
I am speechless!
continue and address the height difference issue and make it perfect!

great beneficial script
thank you for this

Offline Garyhlucas

  • CNC Jedi
  • *****
  • Posts: 1369
    • View Profile
Re: New conic_helical_pocket.vbs with depth and depth increment
« Reply #2 on: December 22, 2014, 00:24:16 am »
Lloyd,
So if you can do Conical Helical Spiral, could you also do Spherical Helical Spiral?  I've been trying to figure out how to cut ball pockets for a delta style 3d printer. The ball mill I would need is too large for my machine and way expensive. I could produce a 3d surface and do it that way but I suspect this would be way better.
Gary H. Lucas

Have you read my blog?
 http://a-little-business.blogspot.com/

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 8331
    • View Profile
Re: New conic_helical_pocket.vbs with depth and depth increment
« Reply #3 on: December 22, 2014, 00:29:56 am »
Fixed.

There were a couple of other problems in there, too.

(same place as before)

Lloyd
"Pyro for Fun and Profit for More Than Fifty Years"

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 8331
    • View Profile
Re: New conic_helical_pocket.vbs with depth and depth increment
« Reply #4 on: December 22, 2014, 00:31:12 am »
Gary,
It would be a pretty simple bit of trig to add to cut hemispheres.

I haven't tried yet, so "famous last words"... but it should be simple.

LLoyd
"Pyro for Fun and Profit for More Than Fifty Years"

Offline Bubba

  • CNC Jedi
  • *****
  • Posts: 2984
    • View Profile
Re: New conic_helical_pocket.vbs with depth and depth increment
« Reply #5 on: December 22, 2014, 00:36:06 am »
Outstanding job as always! I haven't use this or the older vresion. But, never know.. The only problem is, I may forget that script like this exists year from now.. ;D

Thanks Lloyd.
My 2ยข

Win 10 64 bit, CB [1.0} rc 1 64 bit, Mach3, ESS, G540

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 8331
    • View Profile
Re: New conic_helical_pocket.vbs with depth and depth increment
« Reply #6 on: December 22, 2014, 00:43:00 am »
That's OK, Bubba.  I'll forget, too!  ;D

This time, I put my name in it so at least I'll remember that I wrote it -- but only when I see it again!

LLoyd
"Pyro for Fun and Profit for More Than Fifty Years"

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 8331
    • View Profile
Re: New conic_helical_pocket.vbs with depth and depth increment
« Reply #7 on: December 22, 2014, 02:45:03 am »
Ok, Gary.  There's a start for a ball pocket routine in this same forum group, but under a new title.

Lloyd
"Pyro for Fun and Profit for More Than Fifty Years"

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6133
    • View Profile
    • Cambam V1.0 French Doc
Re: New conic_helical_pocket.vbs with depth and depth increment
« Reply #8 on: December 22, 2014, 17:01:52 pm »
Lloyd,
So if you can do Conical Helical Spiral, could you also do Spherical Helical Spiral?  I've been trying to figure out how to cut ball pockets for a delta style 3d printer. The ball mill I would need is too large for my machine and way expensive. I could produce a 3d surface and do it that way but I suspect this would be way better.

Hello,

http://www.cambam.co.uk/forum/index.php?topic=4301.msg30526#msg30526

++
David

Offline Bob La Londe

  • CNC Jedi
  • *****
  • Posts: 3975
  • ^ 8.5 pounds on my own hand poured bait.
    • View Profile
    • CNC Molds N Stuff
Re: New conic_helical_pocket.vbs with depth and depth increment
« Reply #9 on: January 08, 2015, 22:14:48 pm »
Ok... How do I use it?  

~~

Ok... so far so good.  Got it to execute to generate some geometry.  Seems like an engrave mop would be the only way to make use of it.  Same thing I would have had to do if I had generated the helix in CAD.  Now is there an simple easy elegant way to make the engrave mop come out right?  ie: Start with known gemoetry for a thread and get a result that requires little MOP tweaking only. 
« Last Edit: January 08, 2015, 22:23:39 pm by Bob La Londe »
Getting started on CNC?  In or passing through my area?
If I have the time I'll be glad to show you a little in my shop. 

Some Stuff I Make with CamBam
http://www.CNCMOLDS.com

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 4463
    • View Profile
Re: New conic_helical_pocket.vbs with depth and depth increment
« Reply #10 on: January 08, 2015, 22:37:22 pm »
Looking at the NPT details it appears the taper angle is always the same, it's just the diameter and thread pitch that changes.
Made in England

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 8331
    • View Profile
Re: New conic_helical_pocket.vbs with depth and depth increment
« Reply #11 on: January 08, 2015, 23:33:44 pm »
Correct.  It's an easy job if you have a table of the specs.

It would also be a good separate script -- one with a built-in table of standard NPT (and other) thread specs.

Lloyd
"Pyro for Fun and Profit for More Than Fifty Years"