Parametric Involute Bevel and Spur Gears

by GregFrost Jul 19, 2010
Download All Files

Thing Apps Enabled

Please Login to Comment

The 'deprecated' compiler warnings were annoying me, so I've updated the script for OpenSCAD 2015.03-2. It has minimum possible changes, only to get rid of the warnings. I've wrapped in the fix for missing teeth in preview mode too (but that was by someone else).
It's at https://www.thingiverse.com/thing:3561972

parametric involute gear v5.0 for 2015.03
by achrn

has anybody recently got the customizer to work? all I get in customizer is 1 variable, that being Pi = 3.14 etc. Any ideas? I have tried chrome and edge and a few other browsers. Thanks!

Sorry, missread!
What parameters would you like to change? I could "fix" the file and reupload it to my profile ...

You need to edit module _bevel_gearpair() then press F6 (not F5) to create the mesh. This will take a loooooong time!
Inside this module, you can still submit more parameters to the bevel_gear() module - see bevel_gear() for available parameters.
This is valid for v5.0 only.

Is there a .scad available that would produce matching worm drives?

Perhaps this?

Worm gears are a different beast, so you won’t find a “matching” one that matches these gears.

Linear Actuator Worm Gear

Thanks for your reply. These are not exactly what I was looking for.

I've found a .scad for worm drives here: https://www.thingiverse.com/thing:8821/ - it shows a correct preview in OpenSCAD (F5) for me, but the render fails (F6). Maybe I can track down the error, and check if it is producing fitting worm drives when the pitchRadius is set to match the circular_pitch of the gears produced by this thing.

Thank you for sharing this thing, it makes creation of custom sized gears very easy.

Worm Drive, Non-Throated
by syvwlch

Hi, unfortunately, the customizer doesnt work :( When I click it, it says:
/usr/local/bin/openscad/openscad: error while loading shared libraries: libCGAL.so.10: cannot open shared object file: No such file or directory

I would love to see updated version of this library for Open SCAD version 2015.03-3

The "polyhedron(triangles=[])" as well as "assign" are deprecated in newer version of Open SCAD.

Many thanks in advance!

triangles (deprecated in version 2014.03, use faces.

Since 2015.03 assign() is deprecated, as variables can now be assigned anywhere, see 2nd example below. If you prefer this way of setting values, the new Let Statement can be used instead.

I'm using this REGULARLY in my models for an arm mounted, rubber band gatling gun. Thank you for making this available! Because of this great script, I have become somewhat versatile in openscad.

If you are serious about printing, and are looking for a free cad program for your designs, openscad is a powerful place to to start. Excellent work like this allows you to jump right into design with very little learning curve!

Hello, I would like to use this script to recreate a broken gear I have, but cannot understand how to use it.
I can count the number of the teeth (48), the outer diameter 25.2mm and the length/size of a single tooth 1.2mm.
But trying to create it it's not the right size when exported. Could someone help me?



If you open this up in openscad, plug your dimensions into the variable section, compile it, and the display will show you the pitch radius. I bet you'll have to tweak the "circular pitch" value until your gear matches up.

Ok, thanks! I've ended creating a gear with the right number of teeth and then scaled it to match the correct size :-)

Awesome. Thanks for making it available, saved me plenty of time trying to work out this on my own...

There is much of inconsistency with naming of parameters
diametral pitch and circular pitch probably misplaced

Customizer is broken. There's only one field, labeled Pi, with the value of Pi in it.

Comments deleted.

How do you save the bevel gear pair individually?

Just for the record, if you know the module of the gear (i.e. metric gear), then for this script, circular_pitch = 180 * module.

And module * number_of_teeth = pitch_circle_diameter. Hope this helps...

Comments deleted.

Is it possible to specify the outside diameter of a gear, or based on some formula adjust the circular pitch to get a desired gear OD?

Hi using the OpenSCAD fir this thing I'm attempting to Make a replacement gear for a friend it is off a child's electric bike, I have the fundamental shape and the right number of teeth but I cannot figure out how to scale the gear as it is currently too big.

As a picture will be better then me explaining what the gear looks like Linked Image below

Thanks Simon

does anybody know how to remove one of the gears for printing? i would like to print them one at a time.

awesome tool!

@Skeeeee, Not sure if this is what you want but you could comment out each gear then render and export., I did this with the gear I'm attempting to make, if you are unsure then comment out a section then preview finally render to confirm it worked, if there is an issue un-comment the last section.

//gear (circular_pitch=100,
// gear_thickness = 7,
// rim_thickness = 7.6,
// hub_thickness = 7,
// circles=8);

Long winded but would allow you to print one at a time.



First off, thank you for a very useful library. Please don't take this bug report and/or request for help as criticism. I have run into problems with misshapen teeth or non-manifold surfaces on a particular gear (with backlash). I am posting code that reproduces the problem in the hopes that it can serve either as a bug report, or someone can point out what I am doing wrong. Any help would be very much appreciated!

use <parametric_involute_gear_v5.0.scad>;

$fn = 40;

teeth          = 9;
backlash       = 0.7;
circular_pitch = 143;
bore_diameter  = 1.5;

module non_manifold_and_mishapen() {
    // My first attempt at a gear of the correct size for
    // my project gave me this. The surface is non-manifold,
    // and the tips of the teeth are mishapen (when backlash
    // != 0 and for this particular combination of teeth and
    // circular pitch.)
    gear (
        number_of_teeth = teeth,
        circular_pitch  = circular_pitch,
        backlash        = backlash,
        bore_diameter   = bore_diameter,
        hub_thickness   = 1,
        gear_thickness  = 1,
        rim_thickness   = 1

module mishapen_gear_hack() {
    // Here is a hack, showing the results I expect.
    intersection() {
        cylinder(d=8.51, h=100);

module non_manifold_combo() {
    // However, combining this into more complex assemblies
    // invariably makes it non-manifold again.
    difference() {
        union() {
            translate([0, 0, 0.1])
                mirror([0,0,1]) {
                    cylinder( d = 10, h = 1 );
                    cylinder( d = 3,  h = 5 );
        cylinder( d = 2, h = 15,center=true);

translate([-10,0,0])  non_manifold_and_mishapen();
translate([ 10,0,0])  mishapen_gear_hack();
translate([ 20,0,0])   non_manifold_combo();
Comments deleted.

Hi, just tried this out and the bevel gears have no teeth?


I got the key! You have to compile/render it with F6 ;)

does anyone know how to generate a gear that has beveled edges like this?
I am trying to create lens gears for cameras and do not want the lens teeth to touch the build platform. Trying to add a 45º bevel on each tooth

Just intersect it with the union/hull of two appropriately placed cones.

I went to the github directory because I wanted to look at the generation code, but the project seems to have dissipated. Is there another place it could be found?

Great script. Thank you for sharing! I just found out from you about openscad.

For some reason, the customizer doesn't for for this object on my PC on neither Chrome nor IE. Any hints? Both are current on updates. With everyone else successfully using it, I'm pretty sure it's a problem on my end :(

To clarify: When I go into Customizer to size a gear, the only option I'm seeing is a box that sayss 'Pi' next to it.

The Customizer has worked on other objects like electrical receptacles and scenery objects. So I'm mystified on why it won't let me make pretty gears.

Ditto, using maxthon or Chrome.

What's the best way to calculate the bevel gear pair bore base offsets from y0,z0?
I have an existing model that I want to add a 90degree bevel gear pair to, but I need them to be a specific distance apart to fit.
For the small gear, the correct y value appears to be pitch_apex2, but pitch_apex1 for the other gear, seems to be in the middle of the teeth.
pitch_apex1+half_tooth_thickness+gear_thickness seems to be pretty close, but not quite the value I'm after.

If you could add this as a feature, that would be great! but I'd be happy just to know how to calculate it and plug in numbers till I get what I want.

Hi Greg,
Thank you for sharing this terrific SCAD script. One question- is there a way to separate the two gears into two different files? The STL export gives one object with both gears; I want to be able to print them individually.


I second this idea. Thanks for all your hard work in this!

Is there a newer version of this somewhere? I noticed that the involute_bevel_gear_tooth() module has a bug: The triangles are inverted which causes rendering to be wrong in preview mode. The correct triangle ordering should be:
Also, we've almost finalized list comprehension functionality in OpenSCAD, which could significantly reduce the complexity of this script, especially the stitching together of 2D polygons.

Oh, is that why the gears have no teeth? unless one hits F10 or F6. The render() patch below seemed to fix the problem though, at least the teeth show.

For those wanting internal gears, an external gear is one Boolean operation away from an internal gear.

...You would want to reverse the clearance though, since positive clearance on an internal gear would make it TIGHTER.

I was using this to make a set of bevel gears for a 90 degree gearbox. To get gears that look half way reasonable required that the circular pitch be set no smaller than 750. However, this generated large gears. I finally got my head on straight and figured out the work around for this. I made the bore diameters twice the size they needed to be and scaled the gears down 0.5 during slicing. Now I have good looking gears the proper size. This is a great script. It beats me having to learn another programming language. Thanks GregFrost.

Think you could add a root fillet (radius) parameter to the spur gears? I'm finding that my printer doesn't like the sharp inside corners on smaller pitch gears, smoothing that out would be great.

I've just found out that for small gears the resolution for the hub and bore isn't increased appropriately thus one ends up with three sided prisms.

ok cool, so it is not just me lol, I wasn't sure I wasn't just using it wrong. I need a little more functionality from your modules so I am trying my hand at my first bit of openSCAD coding. I will probably host my mods on github, but if you have any design notes you could share here regarding units, I would like to at least annotate your code, since if it is wrong we can atleast warn people lol, or I can be the jerk who forks the code to use proper units, with a note on backwards compatibility.

Yeah yeah. I know. I wish I had realised sooner, but now lots of designs use this so if I changed the definition of circular pitch, it would need to have all designs using this updated. As it is it is in some stupid units like pi/180 mm.

I would vote for correcting units. Designs needs updating, so what?

Every software has bugs, and bugfixes which may break backward compatibility.

The sooner the fix the less break in the future.

Or just release a v2, with a warning, that definition has been changed.
I'm super-grateful to sasa, I tried to debug a year back, but gave up before finding the culprit.


the functionalEnough branch is, well, functional enough. I hope to have 3 new features added today, check the readme file I am trying to document it well. Note my code will still create a backwards compatible gear if you use his old parameters, or you can use the right ones, it is all covered in the readme.


Thank you very much permn00b! I will definietly dive into it.



great! I will probably in the next day or three restructure it a bit. Instead of different modules for different mounting types, I will put it all into the gear module, and have a variable for the type of mounting ie Flange, Set_screw etc

ok cool, so it is not just me lol, I wasn't sure I wasn't just using it
wrong. I need a little more functionality from your modules so I am
trying my hand at my first bit of openSCAD coding. I will probably host
my mods on github, but if you have any design notes you could share
here regarding units, I would like to at least annotate your code, since
if it is wrong we can atleast warn people lol, or I can be the jerk who
forks the code to use proper units, with a note on backwards

ok, I see where this rabbit hole is headed. I need to get this print going before too late today, so I am going to try to churn through this, backwards compatibilty can be preserved by scaling your input numbers and I am going to include that in the readme. If you are interested in trying to keep my new code cohesive with your older stuff let me know and I will work with you on that. The big plus to fixing this error is that you can mate printed gears with industry standard gears you can buy off the shelf, which will matter to some people.
Thank you for doing all the hard work for me though, no way in hell I could have written this from scratch.

well once I understand variable scope a bit better I can stick my kludge into a module (once I learn how modules work...) but I got the code to take standard units and I call that a win. Question for you tho, why is this line like this?

circular_pitch = (circular_pitch!=false?circular_pitch:180/diametral_pitch);

and not
circular_pitch = (circular_pitch==true?circular_pitch:180/diametral_pitch);

as any value inside of circular_pitch should evaluate as true?

False is zero whereas true is a specific value (probably 1) so your line says if they specify a circular pitch of 1 then use it, otherwise use the diametric pitch. The !=false line says if they have specified any circular pitch use it, otherwise use the diametral pitch.

oh see I thougt any non-zero value would evaluate true, so it would be
logically the same as your statement but more readable, but in
retrospect I would agree your way is better. since if this was written
in C++ you could say definitly ANY value will evaluate true, but this is
openscad, and since I don't know that for fact, your method is safer.
This didn't occur to me originally hence the question.

I don't mean to bea jerk, but units man! units! Should really spell that out somewhere. I have been throwing numbers at this till a gear appeared. I am trying to match up to some gears I made in a different program that I no longer have, so took me a while to get usefull results from this. Also since I have never used openscad before it was extra intimidating, and for the record compile-time variables scare the poo out of me, what is this black magic. Otherwise I'd offer to help.

Simple rack and pinion code for reusing in other projects
by sasa

Version in gears (vs version in rack)

First thanks for the scripts-

I got very confused when trying to marry up this rack (http://www.thingiverse.com/thing:6011)http://www.thingiverse.com/thi...
and pinions (http://www.thingiverse.com/thing:3575)http://www.thingiverse.com/thi... and eventually came to the conclusions that
there were errors and bodges in both sets of scripts.

The rack has the "multiplier" bodge (*20) in it. The pinion has a very odd and incorrect definition
of the circular_pitch. Correcting both makes it easy and intuitive to make matching rack and pinions.

(1) the CP in 3575 should be in units of length (ie the distance between teeth defined on the pitch
radius) but in this script it is in units of degrees/radianslength (ie you need to enter a number
bigger than the actual distance you want). Fixing this makes everything a lot easier.

    pitch_diameter  =  number_of_teeth * circular_pitch / pi;
    addendum = cp/pi;
    dedendum = addendum*1.1;
    ... // a few more trivial fixes below

(2) the *20 multiplier bodge in the rack script (6011) - I didn't get to the bottom of this but if the script
is rewritten using the correct CP then it isn't necessary.

module rack(width,thickness,cp,N){
a = 1.0cp/pi; // addendum
d = 1.1
cp/pi; // dedendum
... // more fixes below but you get the idea

Personally I'd drop the diametrial_pitch options - this is much hard to understand than the CP which is
in simple mm/tooth units. Anyone who cares can just use CP=pi/DP.

Printable rack: Modular, parametric ,for rack&pinion system for Reprap
by ckaos
Parametric Involute Bevel and Spur Gears

how to change gear size big and or small?

how cab I customize this?

Hello. I am very new to modeling and OpenSCAD. I am trying to model bevel gears. Can someone please tell me what all I must change in the downloaded code? A step-by-step guide? I would really appreciate it. I have my desired bevel gear dimensions with me. I just don't understand how much and where to enter it all..

I'm a little confused by this line in the gear module
pitch_diameter = number_of_teeth * circular_pitch / 180;

Shouldn't this be
pitch_diameter = number_of_teeth * circular_pitch / pi;

Because of this, the gears generated by the script end up being way smaller than they should be.

How would one design off-center gears similar to those being used on emmet's heart and your own projects? I would like to produce my own kinetic sculpture that "explodes" when rotated. If you have any references I could research I'd greatly appreciate it. I'm sure I could construct on-center bevel gears similar to the first gear cubes but I'm having a hard time wrapping my head around 8 gears who's contact points constantly change.

They are not off centre. They are just reshaped by unioning it with a non-symmetrical shape.

after reading docs here and trying to create a 32DP (diametral pitch) gear model, I have determined that the units must be metric, so to use 32DP (32 teeth per inch diameter) the value entered for Diametral Pitch should be 32/25.4 hence the gear is

module testDPGear()
}this is now working as I expected thank you Greg for a fantastic tool!

Is it possible to use this script to create racks?  If so, what are the correct parameters to create a matching "normal" and rack gear?

When i try to generate a gear with my own parameters, i only get some sort of rod. My parameters: gear (circular_pitch=0.051181,

number_of_teeth = 20,

gear_thickness = 0.066929,

rim_thickness = 0.066929,

hub_thickness = 0.066929,

hub_diameter = 0,

bore_diameter = 0.086614,

twist = 0,


The gear is 1,68 mm thick. As far as i understand the programm takes imperial values so i´ve converted the values to inches.
Can anyone tell me what i´m doing wrong?

pro tip: wrap the actual operations of the teeth inside render(), that will significantly simplify the CSG trees (and thus make previews work better).


Thanks mashiara
I applied the patch and now the gears have teeth with out having to hit F6 or F10. And it seems faster also.

I have a license question. Are the gears made (the stls) also LGPL? Or can I consider them to be whatever license I wish, as it's L GPL, and not GPL, as long as I haven't changed your scad script, but I'm just using it? I'm asking as my thing where I included a gear made by your script was criticized for including your part on my page, since my thing has a different license. Now I've noted in the description that your part is LGPL, and hope this is ok, but it'd be good to get a clarification from you. My thing is on: http://www.thingiverse.com/thing:15611http://www.thingiverse.com/thi... (And thanks for a great and very useful script, as well as all the other parts you've designed that I use frequently!)

Alu reprap
by larsie

The output of a gpl/lgpl program is not goverened by the gpl/lgpl.

You caqn do with it whatever you like.

who can help me!

i need 2 gears

1st - 108 thooth /modulus 1/ 3mm thick

2nd - 20 thooth / modulus 1 / 3mm thick

which settingsmust i use


a 20 thooth bevelgear / modulus 1

same question


I'm confused with one of the comments below, are the measurements in imperial or metric?

What is the unit for the parameter outside_circular_pitch?

You are calculating:
outside_pitch_radius1 = gear1_teeth outside_circular_pitch / 360;
outside_pitch_radius2 = gear2_teeth
outside_circular_pitch / 360;
This looks somewhat like you are actually calculating some circumference instead of a radius
but I haven't yet found my way around the formul

(In software development it's accepted and often even enforced practice
to have a comment in front of a method to document not only it's purpose
but it's parameters and their allowed values too.)

I could use some help.

Given a dedendum circle(and shaft)-Diameter of exactly 75,3(65,5mm) mm and something like 35(8mm)mm.

How do I calculate sensible parameters for bevel_gear_pair()? DONT_KNOW

Preferably with a 0.8/ 32 pitch. (An industry standard for the application I have in mind.)

Well, I'm trying to enter a pitch of 32 and doing a binary search to find the correct number of teeth to get my diameter.

Somehow this is extremely slow.

The first 2 runs took
gt; 2 minutes on a 2x2.8GHz with 8GB or Memory.

The third one is running for more then 15 MINUTES now. (parameter: 80, 20, , 32)

OpenSCAD is using 320MB of memory already and adding megabytes by the second.

Could there be a massive memory leak?

Okay, there are memory leaks the size of the UK.

It runs much faster if you stop and re-start OpenSCAD every time you run it.

This is great but I am having a little difficulty working with it. I need 2 spur gears that mesh together that have a 6:1 gear ratio. The largest gear can be no larger than 40.64 mm can someone help me set this up?

//6:1 is a pretty high ratio for such small gears:


gear (circular_pitch=circular_pitch,
gear_thickness = 3,
rim_thickness = 4,
hub_thickness = 6,

gear (circular_pitch=circular_pitch,
gear_thickness = 3,
rim_thickness = 4,
hub_thickness = 0,

I was totally failing to generate an actual gear with my own numbers and then I realized that gears are typically imperial! Converted my metric to inches and bam! A gear with teeth! Doh.

Another little gotcha is when you load up the STL into ReplicatorG the gear will be TINY! I guess the STL file can specify a unit so you'll need to use the scale tool to go from inches to mm.

Made a pair of these, using the simple gear template. They meshed perfectly, rotated 1:2 like they should, and taught me something about why the teeth on gears aren't flat.

Entirely rad. Thanks.

I tried it, I printed some gears, but Im unable to create meshing inside gear and external gear.

Making a difference from a plain cylinder is not working. Some clearence needs to be adding.

Can you extend this script to have inside gears? They allow to create more compact design, and Im desperately looking for a solution.

I would like to have herringbone inside gear...


I've been working with internal gears for my gearbox.

I had to make some modifications to the library to get it to work. I added a way to adjust the addendum
amp; dedendum. The addendum is defined as 1/pitch_diametrical, I changed it so that you can set it to something like 1.25/pitch_diametrical so that you can make the tooth taller do so that when you subtract the gear from something it leaves more room, alternatively, you could have another clearance adjustment that increases the addendum instead of the dedendum. I also found some documentation on the net implying that the dedendum should be more like 1.4/pitch_diametrical for fine pitched gears but that adjustment can easily be made with the clearance parameter.

Can you post a pic of the gears you printed that don't mesh? I though internal gears were the made just as you suggest (i.e. the negative of an external gear), but I think there are some limitations on the teeth ratios. Have you tried using the backlash parameter? That will give some clearance between the teeth.

Actually, if you are taking the negative of a gear, you would need negative backlash... I havent tried that.

Thank you, I will try out with negative backlash.

Also I can try out only after a week or so. I will definietly update you here.

Thanks for the support. I try to make some photos to discuss it further.

is it possible to make a bevel gear the same size as the large gear? i want to make a lens focus gear but i want to eliminate the 90
º junction box on most traditional designs. if i print it with a bevel gear that fits on the lens and another the same size but with a much smaller bore diameter that is attached to a knob will that work?

basically something like this with bevel gears

That large gear is a bevel gear! It looks like a circular rack because of the combination of the teeth ratio and the axis angles. If either the axis angles were closer together or the second gear was much larger, it would be obvious that both gears are bevel gears.

This is an amazing script. There is so much functionality here that an instruction manual would be amazing. Nothing to fancy but a simple wiki page or something. I have the script running and am working my way through the commented code now.

Thanks for a great addition

To be honest, I thought the documentation on this page would be sufficient. I guess that is the problem with open source software. It is hard to be a good judge of what documentation is required when you have been intimately involved in the development.

without knowing much about openscad its hard.. took me a while to realize that openscad is a stand alone application :) i kept trying to figure out how to make this work in a 3d application

Amazing scad work! Such a useful library and good variety of gear types!!

I have made an update allowing a gear to be made 2D for exporting to a laser cutter. The update is here http://www.thingiverse.com/thing:3752http://www.thingiverse.com/thi....

If you want to pull the changes into your code and release a new version/ add it to the next release that would be great :)

Thanks again for the good work!

Update to Parametric Involute Bevel and Spur Gears V5.0
by Amp

w00t! Thanks for making everything work and awesome Greg! I didn't even realize this was based on my script until i checked GitHub today XP

The bevel gears are missing their teeth :)

For some reason, it sometimes renders without teeth using the F5 option. Using F6 takes a lot longer but always results in the teeth showing up. I just did this in a small script:

F5 produced what you have shown. F6 rendered the gear properly. If you hit F12, you can see the component objects including the teeth. This must be some sort of limitation in the OpenCSG viewer.

if you put a render() statement in module bevel_gear() before it calls involute_bevel_gear_tooth, the problem is solved

that was from bevel_gear() with default parameters. Others seem to work great.

Could please licence this as "GPL 2 or later", to allow it to be properly included in the MCAD lib (http://github.com/elmom/MCAD)http://github.com/elmom/MCAD). LGPL would work also.

"gpl2 or later" didn't seem to be an option. I have gone with LGPL.

Great, thanks. Even just clarifying the license here or in the code would've been good, but LGPL works.

I'll try to make a release and blog it some day, the lib already has other great additions also.

This Thingiverse page says "LGPL", but the file itself says "GPL". Would it be possible to change either the file or the page so they're the same?

Could you add inverted gears (think planetary) to your script. The sign of the radii/pitch parameters could act as the switch. You can take a look at http://www.swineworld.org/blender/gears/http://www.swineworld.org/blen... which has a script for generating gears in blender. http://www.thingiverse.com/thing:505 has an example usage similar to what I'm planning (gearing for a gearbox for attaching to a drill chuck etc).

Planetary gear calling card (MakerBot Printable Version)

Flagging this as a derivative isn't obvious. The way I know how to do it is to press the "I made one!" on the thing to be derived and the form that opens has the option to add your changes. From there it uses the normal widget for thing editing.

Obviously this won't work after adding the derived thing.

would be super cool to have this type of scad libraries in some sort of svn/git ..

thanks for the superb work :) I'v bin trying to make script that does the same thing for few weeks and was not able to properly design involute shape in openscad.

http://github.com/D1plo1d/MCADhttp://github.com/D1plo1d/MCAD is the working address for the MCAD lib, from which some code was used for this script. I'm adding this script to my fork on github at least.

Very nice work, incredibly useful.

Wow! amazing script!

Are you sure this isnt some sort of black magic?

WOW. This is greatness. Any gear, any size, any type. From my perspective, the single most useful thingiverse post yet.

Thanks! That's high praise indeed! The script does represent about a weeks worth of research and development work. I think it does a good job showcasing the power of Openscad (and trigonometry).