Skip to content

Commit 3914a04

Browse files
Merge pull request #13 from CadQuery/gear
Add another involute gear example
2 parents 2e8e9db + a782280 commit 3914a04

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ A place to share CadQuery scripts, modules, tutorials and projects
5757

5858
* [3D_Printer_Extruder_Support.py](examples/3D_Printer_Extruder_Support.py) - Designed for mounting hotend to an i3 X-carriage inspired by the P3steel Toolson
5959

60+
* [Involute_Gear.py](examples/Involute_Gear.py) - Fast involute gear generator.
61+
62+
<img src="examples/images/Involute_Gear.png" width="600"/>
63+
6064
### Tutorials
6165

6266
* [Ex000 Start Here.ipynb](tutorials/Ex000%20Start%20Here.ipynb) - iPython notebook that is the entry point for a set of CadQuery tutorials

examples/Involute_Gear.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
from cadquery import Workplane, Edge, Wire, Vector
2+
from math import *
3+
4+
5+
def involute_gear(m, z, alpha=20, shift=0, N=20):
6+
'''
7+
See https://khkgears.net/new/gear_knowledge/gear_technical_reference/involute_gear_profile.html
8+
for math
9+
'''
10+
11+
alpha = radians(alpha)
12+
13+
# radii
14+
r_ref = m*z/2
15+
r_top = r_ref + m*(1+shift)
16+
r_base = r_ref*cos(alpha)
17+
r_d = r_ref - 1.25*m
18+
19+
inv = lambda a: tan(a) - a
20+
21+
# angles of interest
22+
alpha_inv = inv(alpha)
23+
alpha_tip = acos(r_base/r_top)
24+
alpha_tip_inv = inv(alpha_tip)
25+
26+
a = 90/z+degrees(alpha_inv)
27+
a2 = 90/z++degrees(alpha_inv)-degrees(alpha_tip_inv)
28+
a3 = 360/z-a
29+
30+
# involute curve (radius based parametrization)
31+
def involute_curve(r_b,sign=1):
32+
33+
def f(r):
34+
alpha = sign*acos(r_b/r)
35+
x = r*cos(tan(alpha) - alpha)
36+
y = r*sin(tan(alpha) - alpha)
37+
38+
return x,y
39+
40+
return f
41+
42+
# construct all the profiles
43+
right = (
44+
Workplane()
45+
.transformed(rotate=(0,0,a))
46+
.parametricCurve(involute_curve(r_base,-1), start=r_base, stop = r_top, makeWire=False, N=N)
47+
.val()
48+
)
49+
50+
left = (
51+
Workplane()
52+
.transformed(rotate=(0,0,-a))
53+
.parametricCurve(involute_curve(r_base), start=r_base, stop = r_top, makeWire=False, N=N)
54+
.val()
55+
)
56+
57+
top = Edge.makeCircle(r_top,angle1=-a2, angle2=a2)
58+
bottom = Edge.makeCircle(r_d, angle1=-a3, angle2=-a)
59+
60+
side = Edge.makeLine( cq.Vector(r_d,0), cq.Vector(r_base,0))
61+
side1 = side.rotate(cq.Vector(0, 0, 0), cq.Vector(0, 0, 1), -a)
62+
side2 = side.rotate(cq.Vector(0, 0, 0), cq.Vector(0, 0, 1), -a3)
63+
64+
# single tooth profile
65+
profile = Wire.assembleEdges([left,top,right,side1,bottom,side2])
66+
profile = profile.chamfer2D(m/4, profile.Vertices()[-3:-1])
67+
68+
# complete gear
69+
res = (
70+
Workplane()
71+
.polarArray(0,0,360,z)
72+
.each(lambda loc: profile.located(loc))
73+
.consolidateWires()
74+
)
75+
76+
return res.val()
77+
78+
79+
show_object(
80+
Workplane(obj=involute_gear(1, 20)).toPending().twistExtrude(20, 30)
81+
)

examples/images/Involute_Gear.png

109 KB
Loading

0 commit comments

Comments
 (0)