DXF generator for involute gears

by clifford, published

DXF generator for involute gears by clifford Jul 26, 2009

Featured Thing!



DXF generator for involute gears by clifford is licensed under the GNU - GPL license.

Liked By

View All

Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag.

Print Thing Tag

Thing Statistics

25013Views 3593Downloads


A small python script for generating DXF designs of involute gears.

Without an output file the generated gear is displayed in a (tkinter) window instead of generating a DXF file.

The script is licensed under the terms of GNU GPL. This however does not have any influence on the DXF files you generate with it..

Created during Hackathon 2.0 at Metalab, Vienna:

Link to subversion (check for latest version):


Usage example:
python gearsgen.py -n 5 -m 1 -c 0.5 -f mygear.dxf

Help message as generated by 'python gearsgen.py --help':

Usage: python gearsgen.py [ options ]


-i ....... generate outline for internal gear
(this means the meaning of pitch and clearance
is inverted the sign of the spacing is changed)

-n N ..... number of teeth (default = 5)

-m U ..... module (default = 1.0)
(for gears to mesh, their modules must be equal. the gears
working diameter is [number of teeth] times [module])

-c X ..... clearance (default = 0.0)
(move the gear bottom land down by this number of milimeters)

-a X ..... addendum offset (default = 0.0)
(move the gear top land up by this number of milimeters by
incrasing the addendum by this value. use with care!)

-p X ..... pitch (default = 0.0)
(move the gear top land up by this number of milimeters by
linearly extending the top land. do not confuse with '-a'!)

-s X ..... spacing (default = 0.0)
(move the flanks inside by this number of milimeters.)

-e ....... generate only DXF entities without DXF header or DXF footer
(usefull for creating larger dxf files from a script)

-l T ..... name of the DXF layer for generated entities
(without this option, no layer information is added to the DXF)

-x X ..... add this value to all X-coordinates in the generated DXF file
-y X ..... add this value to all Y-coordinates in the generated DXF file
-r X ..... rotate the generate wheel by this ange in degrees
(this can be used together with -e and -l to generate more complex
DXF files from scripts. default oriantation is gear at 0/0 with
a bottom land facing to the positive x-axis)

-f T ..... name of the DXF file to generate
(without this option, a (tk) window is opend and the generated gear
is displayed. note that the gear is scaled to fit the viewport.)

Argument types as used in abve options reference:
N = positive integer
U = unsigned decimal number
X = signed decimal number
T = text

All Apps

Upgrade this Thing with Thingiverse Apps

No results.

You have millions of parameters.

A gear is defined normally with the following parameters:

diametral pitch: P (US) or Module (metric): m

tooth: N

Pressure angle: PA

Also the script is not correct.
For an involute profile gear these are the circles:
Root circle (root diameter: DR)
Base circle (base diameter: DB)
Pitch circle (pitch diameter: DP or D)
Outside circle (outside diameter: DO)

The involute profile start at the BASE circle and stops at the outside
In your script you dont follow the official notation, or simply you mix the circles, but at the end, the involute profile in your case starts at the ROOT circle.

Also the adendum and dedendum calculations are wrong too.
The adendum equals to module (metric) or 1/P (diametral pitch, US).
e dedendum is constantadendum. There are standards for the "constant", but it is 1.25-1.4 for metrics.

: (BS4582, DIN 867, DIN 58412, AGMA 207.06 and DIN 58400 where the adendum and dedendum had other definitions: a = 1.1m, d = 1.5*m)

Also I dont fully understand how you determine the stoppin
g angle....
(especially why x=r1*phi is used in involute_intersect_with_r2).

Best regards,

ps: Maybe I'll go the oldscool method, and draw the involute profile gear in Qcad by hand...

Well.. It wasn't easy to get good information online and some of the stuff I've found even was inconsistent with the rest. So I did as good as I could with what I had...

You seam to have some background in the field. I'd love to see a fixed/improved version of my script from you as derived thing here on thingiverse..

gt; Also I dont fully understand how you determine the stopping angle....

gt; (especially why x=r1*phi is used in involute_intersect_with_r2).

My bad. It is the correct involute mathematical functions.
x = rcos(phi)+rphisin(phi)
y = r

Also I could not manage to a reliable source, where it lists the maximum number of teeths for lets say module=2.0
Seems like 41 is the theoretical maximum, but the root and base diameter are really close(77.0 vs. 77.05), above that the root diameter is bigger than the base diameter, which is a no-go.

If somebody manage to hunt down some kind of confirmation, or some guidelines, what are the minimum distance between the root diameter and base diameter (maybe 35 teeths are too many already), would be really helpful!

For Python 3, the print commands need to be changed to the function format, which can be done using a python script. Assuming the default windows path for Python 3.1

c:\Python31\Tools\Scripts\http://2to3.py2to3.py -w -n http://gearsgen.pygearsgen.py

Other than the automatic changes, there is one other change needed

for i in range(len(linedata)/4):
needs to become (in 3 places)
for i in range(len(linedata)//4):

Thanks for such a useful script. I intend to write an Autohotkey GUI wrapper for this.

I've now changed the print statements to the function format and are using the integer division in the range statements (see latest svn version).

I don't have python3 on my machine so please let me know if anything else needs to be changed to make the script python3 compatible..

I tried running this withing cygwin and get this error. I am running python2.4

python http://gearsgen.pygearsgen.py -n 10 -m 3 -f output.dxf

Traceback (most recent call last):
File "http://gearsgen.pygearsgen.py", line 287, in ?
f.write(" 10\n{0}\n".format(x1 + off_x))
AttributeError: 'str' object has no attribute 'format'

the str.format() function has been introduced in python 2.6 and replaces the old % operator for string formating. please use the script with at least python 2.6.

This is awesome! Thanks!

Yay! More scripts! The parametric space of open source objects is growing!