Last active
August 2, 2021 19:11
-
-
Save jschoch/39b7f7299f9205ce0cada857d0ec7861 to your computer and use it in GitHub Desktop.
A cadquery model of a shaper cutting a gear, should allow you to simulate how a tool geometry will behave
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cadquery as cq | |
import math | |
pitch_diameter = 12 | |
blank_diameter = 12.995 | |
depth = 1.17 | |
#indicates angle | |
gear_blank = ( | |
cq.Workplane("front") | |
.circle(blank_diameter/2) | |
.extrude(1) | |
.box(10,.1,2) | |
) | |
#this determines how fine the tooth is, keep small to keep fast | |
steps =50 | |
travel_distance_x = 6 | |
old_y_pos = -(travel_distance_x/2) | |
y_pos = old_y_pos | |
step_linear = travel_distance_x / steps | |
tooth_count = 24 | |
step_degree = (360)/ ((pitch_diameter * math.pi )/step_linear) | |
print(f'Step Linear X {step_linear} Step Degree {step_degree}') | |
tool_tip_width=.15 | |
pressure_angle = 30 | |
x_gear_tool_start_pos = (blank_diameter/2)- depth | |
gear_tool = ( | |
cq.Workplane("front") | |
.transformed(offset=(x_gear_tool_start_pos,old_y_pos, 0.0), rotate=(0, 0, 0)) | |
.vLine(tool_tip_width/2) | |
.polarLineTo(5,pressure_angle) | |
.hLineTo(8) | |
.vLineTo(0.0) | |
.mirrorX() | |
.extrude(3) | |
) | |
def cut_tooth(): | |
global y_pos | |
global gear_blank | |
global old_y_pos | |
global gear_tool | |
for x in range(0,steps,1): | |
y_pos = y_pos + step_linear; | |
gear_tool = gear_tool.translate((0,step_linear,0)) | |
gear_blank = gear_blank.rotate((0,0,0),(0,0,-1),-step_degree ).cut(gear_tool) | |
print(f'G91 X{step_linear}') | |
print(f'G91 A{step_degree}') | |
#rotate back to beginning | |
gear_blank = gear_blank.rotate((0,0,0),(0,0,-1),step_degree*steps ) | |
y_pos = old_y_pos | |
for tooth in range(3): | |
cut_tooth() | |
#rotate one tooth | |
gear_blank = gear_blank.rotate((0,0,0),(0,0,-1),(360/tooth_count)) | |
#move tool back to beginning | |
gear_tool = gear_tool.translate((0,-(step_linear * steps),0)) | |
# Displays the result of this script | |
#show_object(gear_blank) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cadquery as cq | |
import math | |
pitch_diameter = 24 | |
gear_blank = ( | |
cq.Workplane("front") | |
.circle(29.506/2) | |
.extrude(1) | |
.box(12,.1,2) | |
) | |
#this determines how fine the tooth is, keep small to keep fast | |
steps =30 | |
old_y_pos = -7.5 | |
travel_distance_x = 15 | |
pitch_diameter = 24 | |
y_pos = old_y_pos | |
step_linear = travel_distance_x / steps | |
tooth_count = 12 | |
step_degree = (360)/ ((pitch_diameter * math.pi )/step_linear) | |
print(step_degree) | |
tool_tip_width=2 | |
pressure_angle = 20 | |
gear_tool = ( | |
cq.Workplane("front") | |
.transformed(offset=(10.,old_y_pos, 0.0), rotate=(0, 0, 0)) | |
.vLine(tool_tip_width/2) | |
.polarLineTo(5,pressure_angle) | |
.hLineTo(8) | |
.vLineTo(0.0) | |
.mirrorX() | |
.extrude(3) | |
) | |
def cut_tooth(): | |
global y_pos | |
global gear_blank | |
global old_y_pos | |
global gear_tool | |
for x in range(0,steps,1): | |
y_pos = y_pos + step_linear; | |
gear_tool = gear_tool.translate((0,step_linear,0)) | |
gear_blank = gear_blank.rotate((0,0,0),(0,0,-1),-step_degree ).cut(gear_tool) | |
#rotate back to beginning | |
gear_blank = gear_blank.rotate((0,0,0),(0,0,-1),step_degree*steps ) | |
y_pos = old_y_pos | |
for tooth in range(2): | |
cut_tooth() | |
#rotate one tooth | |
gear_blank = gear_blank.rotate((0,0,0),(0,0,-1),(360/tooth_count)) | |
#move tool back to beginning | |
gear_tool = gear_tool.translate((0,-(step_linear * steps),0)) | |
# Displays the result of this script | |
#show_object(gear_blank) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cadquery as cq | |
import math | |
pitch_diameter = 12 | |
blank_diameter = 12.995 | |
depth = 1.17 | |
#indicates angle | |
gear_blank = ( | |
cq.Workplane("front") | |
.circle(blank_diameter/2) | |
.extrude(1) | |
.box(10,.1,2) | |
) | |
#this determines how fine the tooth is, keep small to keep fast | |
steps =26 | |
travel_distance_x = 7.5 | |
old_y_pos = -(travel_distance_x/2) | |
y_pos = old_y_pos | |
step_linear = travel_distance_x / steps | |
tooth_count = 24 | |
step_degree = (360)/ ((pitch_diameter * math.pi )/step_linear) | |
print(f'Step Linear X {step_linear} Step Degree {step_degree}') | |
a_feed = 300 | |
xy_feed = 1800 | |
tool_tip_width=.15 | |
pressure_angle = 30 | |
x_gear_tool_start_pos = (blank_diameter/2)- depth | |
gear_tool = ( | |
cq.Workplane("front") | |
.transformed(offset=(x_gear_tool_start_pos,old_y_pos, 0.0), rotate=(0, 0, 0)) | |
.vLine(tool_tip_width/2) | |
.polarLineTo(5,pressure_angle) | |
.hLineTo(8) | |
.vLineTo(0.0) | |
.mirrorX() | |
.extrude(3) | |
) | |
render = 1 | |
gcode = 1 | |
y_feed = 5 | |
#s_mm = 252.0 | |
s_mm = 31.7 | |
factor = s_mm/360 | |
if(gcode): | |
for x in range(10): | |
print("\n") | |
def cut_tooth(): | |
global y_pos | |
global gear_blank | |
global old_y_pos | |
global gear_tool | |
global render | |
global gcode | |
global y_feed | |
global factor | |
for x in range(0,steps,1): | |
y_pos = y_pos + step_linear; | |
if(render): | |
gear_tool = gear_tool.translate((0,step_linear,0)) | |
gear_blank = gear_blank.rotate((0,0,0),(0,0,-1),-step_degree ).cut(gear_tool) | |
if(gcode): | |
print(f'G1 F{xy_feed} G91 Y{step_linear}') | |
print(f'G1 F{a_feed}G91 A{-step_degree * factor}') | |
print(f'G1 F{xy_feed}G91 X{y_feed}') | |
y_feed = y_feed * -1 | |
#rotate back to beginning | |
if(render): | |
gear_blank = gear_blank.rotate((0,0,0),(0,0,-1),step_degree*steps ) | |
if(gcode): | |
print(f'G1 F{xy_feed} G91 A{(step_degree*factor)*steps}') | |
print(f'G1 F{xy_feed} G91 Z10') | |
print(f'G90 Y0X0') | |
print(f'G91 Z-10') | |
y_pos = old_y_pos | |
for tooth in range(3): | |
#for tooth in range(tooth_count): | |
cut_tooth() | |
#rotate one tooth | |
if(render): | |
gear_blank = gear_blank.rotate((0,0,0),(0,0,-1),(360/tooth_count)) | |
#move tool back to beginning | |
gear_tool = gear_tool.translate((0,-(step_linear * steps),0)) | |
if(gcode): | |
print(f'G91 A{(360/tooth_count)*factor}') | |
#print(f'') | |
if(gcode): | |
for x in range(10): | |
print("\n") | |
# Displays the result of this script | |
#show_object(gear_blank) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment