CamBam
News:
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
March 30, 2020, 14:25:13 pm


Login with username, password and session length


Pages: [1]
  Print  
Author Topic: New conic_helical_pocket.vbs with depth and depth increment  (Read 7882 times)
lloydsp
CNC Jedi
*****
Online Online

Posts: 8172



View Profile
« 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 » Logged

"Pyro for Fun and Profit for More Than Fifty Years"
GraphicMan
Droid
**
Offline Offline

Posts: 80


View Profile
« 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
Logged
Garyhlucas
CNC Jedi
*****
Offline Offline

Posts: 1342


View Profile
« 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.
Logged

Gary H. Lucas

Have you read my blog?
 http://a-little-business.blogspot.com/
lloydsp
CNC Jedi
*****
Online Online

Posts: 8172



View Profile
« 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
Logged

"Pyro for Fun and Profit for More Than Fifty Years"
lloydsp
CNC Jedi
*****
Online Online

Posts: 8172



View Profile
« 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
Logged

"Pyro for Fun and Profit for More Than Fifty Years"
Bubba
CNC Jedi
*****
Offline Offline

Posts: 2864



View Profile
« 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.. Grin

Thanks Lloyd.
Logged

My 2ยข

Win 10, CB [1.0} rc 1, Mach3, ESS, G540
lloydsp
CNC Jedi
*****
Online Online

Posts: 8172



View Profile
« Reply #6 on: December 22, 2014, 00:43:00 am »

That's OK, Bubba.  I'll forget, too!  Grin

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
Logged

"Pyro for Fun and Profit for More Than Fifty Years"
lloydsp
CNC Jedi
*****
Online Online

Posts: 8172



View Profile
« 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
Logged

"Pyro for Fun and Profit for More Than Fifty Years"
dh42
Administrator
CNC Jedi
*****
Offline Offline

Posts: 5840



View Profile WWW
« 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
Logged
Bob La Londe
CNC Jedi
*****
Offline Offline

Posts: 3884


^ 8.5 pounds on my own hand poured bait.


View Profile WWW
« 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 » Logged

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
EddyCurrent
CNC Jedi
*****
Offline Offline

Posts: 4207



View Profile
« 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.
Logged

Made in England
lloydsp
CNC Jedi
*****
Online Online

Posts: 8172



View Profile
« 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
Logged

"Pyro for Fun and Profit for More Than Fifty Years"
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.162 seconds with 19 queries.

Copyright © 2018 HexRay Ltd. | Sitemap