o300 sub (Created by Adam Ziegler and SWpadnos ) (o300 call [1 x pos] [2 y pos] [3 safety height] [4 top] [5 depth] ) ( [6 tool diam] [7 minor diam] [8 thead depth] [9 turns per unit length] ) ( [10 start angle] [11 right/left thread] ) ( [12 helical infeed / radial infeed] ) #14 = [#4-#5] (bottom z of thread) #15 = [#7/2+#8-#6/2] (distance from center to cut depth of thread) #16 = [#1+COS[#10]*#15] (set x start) #17 = [#2+SIN[#10]*#15] (set y start) #18 = [1/#9] (depth per revolution) #19 = [#4] (reset depth stop) g0 z#3 (rapid to saftey height) x#1y#2 (rapid to center) g1 z#4 x#16y#17 o301 if [#11 eq 1] #11 = [3] o301 else #11 = [2] o301 endif (re does 303 twice since #19 becomes lt on a #19 =) o302 while [#19 gt #14+#18/1000] (#18/1000 is a fudge factor due to floating point problems) #19 = [#19-#18] o303 if [#19 lt #14] #20 = [#5*#9*360+#10] #21 = [#1+COS[#20]*#15] #22 = [#2+SIN[#20]*#15] g[#11] x[#21] y[#22] i[#1-#16] j[#2-#17] z[#14] o303 else g[#11] x[#16] y[#17] i[#1-#16] j[#2-#17] z#19 o303 endif o302 endwhile g0 x#1y#2 g0 z#3 o300 endsub (****** Example: ) ( 1.25" diameter hole centered on [1.5],[1] ) ( 0.5" diameter tool saftey height of 2.25" ) ( Right hand 18 pitch screw with 0.01" deep thread 3" long ) ( Thread starts 45 degrees clockwise from the 12:00 position) F30 o300 call [0] [0] [.5] [0] [.9275] [0.5] [1.25] [0.01] [10] [0] m30