<p>Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.</p></p><strong>First time visiting? Here are some places to start:</strong></p><ol style="list-style:inherit;margin-left:25px;"><li>Looking for a certain topic? Check out the <a href="https://forum.onshape.com/categories">categories filter</a> or use Search (upper right).</li><li>Need support? <a href="https://forum.onshape.com/post/question/community-support">Ask a question</a> to our <a href="https://forum.onshape.com/categories/community-support">Community Support</a> category.</li><li>Please submit support tickets for bugs but you can request improvements in the <a href="https://forum.onshape.com/categories/product-feedback">Product Feedback category</a>.</li><li>Be respectful, on topic and if you see a problem, Flag it.</li></ol><p>If you would like to contact our Community Manager personally, feel free to <a href="https://forum.onshape.com/profile/6/LouGallo">send a private message</a> or <a href="mailto:lgallo@onshape.com">an email</a>.
</p>
</p>
Bevel gear pair generator
fma
Member Posts: 87 ✭✭
Hi!
I started to learn FeatureScript by writing a bevel gear pair generator. I already did such generator using OpenScad, so this is more a port than a complete writing. So far, I successfully generate the gear pair without teeth; gears are represented by their primitive diameters. Here is my code:
https://cad.onshape.com/documents/9b04fb889def400dfd4a693f/w/dfc27fc3b2e79b5b8271c77f/e/786005a281331572a0efe88b
Even if I have a teeth routine in my Openscad design (not written by me), I think it would be better to use code from the FeatureScript 'Spur Gear', written by Neil:
https://cad.onshape.com/documents/5742c8cde4b06c68b362d748/v/c65839fc6078faeb4d2aece1/e/01a666571e625f8b819fd75b
Before going further, I would be interested by your feedback about my code; as it is my first FeatureScript, it is certainly not optimized! Feel free to comment; the idea is to have a good base to implement the next stop: adding teeth! Any advice for this welcome to.
Thanks,
PS : my OpenScad design is at the end of the FeatureScript.
I started to learn FeatureScript by writing a bevel gear pair generator. I already did such generator using OpenScad, so this is more a port than a complete writing. So far, I successfully generate the gear pair without teeth; gears are represented by their primitive diameters. Here is my code:
https://cad.onshape.com/documents/9b04fb889def400dfd4a693f/w/dfc27fc3b2e79b5b8271c77f/e/786005a281331572a0efe88b
Even if I have a teeth routine in my Openscad design (not written by me), I think it would be better to use code from the FeatureScript 'Spur Gear', written by Neil:
https://cad.onshape.com/documents/5742c8cde4b06c68b362d748/v/c65839fc6078faeb4d2aece1/e/01a666571e625f8b819fd75b
Before going further, I would be interested by your feedback about my code; as it is my first FeatureScript, it is certainly not optimized! Feel free to comment; the idea is to have a good base to implement the next stop: adding teeth! Any advice for this welcome to.
Thanks,
PS : my OpenScad design is at the end of the FeatureScript.
0
Comments
-
Hi,
Looks like a great project! One suggestion: when you post a link to your document in the forum, please make a version first and post a link to the version. Otherwise, we can't see the functioning state -- it looks like you're in the middle of editing your code and it's temporarily broken.Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc0 -
Sorry for that! Here is a working version:
https://cad.onshape.com/documents/9b04fb889def400dfd4a693f/v/f4e7bddcdb7b3b08522113d5/e/786005a281331572a0efe88b
0 -
That looks better

One note -- I'm not an expert on gear math, but the bevel gear tooth shape is different than the spur gear tooth shape. Googling talks about something called an "octoid", but finding equations for it seems harder.Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc0 -
I didn't know that! Thanks for the information, I'll dig that point. I already 3D printed such gears, generated with my OpenScad script, and they work fine. I guess that I don't really need a perfect gear profile in this case, but I will try to write a correct FeatureScript.
What about the code? I don't like much the duplication; any advice to avoid that?0 -
I expect that gears with imperfect teeth will still work, but they'll have more noise/wear/friction than necessary.
Regarding code duplication, I think the way to avoid it is similar to what you did in OpenSCAD: write a function that creates a single beveled gear and call it twice, once for each in the pair. Making the function argument a map tends to make the code more readable IMO (that's why definition for feature is a map).Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc0 -
Ok, thanks. I'm working on the teeth, and I will refactor the code once I get something working.0
-
If your looking for some reference formulas for the gear teeth, I would recommend doing a search for "Elements of Metric Gear Technology".
It's a great resource that explains the theories and formulas for a bunch of different gear types.2 -
Very interesting! Thanks for pointing.0
-
Be prepared to spend a lifetime of learning in the realm of true gear teeth profiles...an enormously complex field if you factor in all the types of gearing and all the modifications that can be applied in a high number of scenarios. For 3D printing - you can probably get by with a more simplistic approach. Usually 3D printers can't match the accuracy needed and often plastics are pretty compliant anyways. Smooth running and wear will be affected - but if you're 3D printing gears, you probably don't care about these things as much at this stage of the design process.
The stiffer the material/geometry and the more critical the applications - the greater the need for accurate profiles. Gear designers usually don't worry about trying to model gear teeth accurately for those scenarios. They usually have a symbolic representation of the model and place the qualifying information on a drawing that is meant for manufacturing information and QA requirements based on the manufacturing equipment and inspection equipment being used to make/validate the parts. I've attached a sample set of qualifying information for a simple spur gear set
Another set of good resource on gears and profile information is any book by one of the pioneers of modern gear design: Earle Buckingham. Here's one: https://www.amazon.com/Analytical-Mechanics-Gears-Earle-Buckingham/dp/0486657124
By the way, kudos on approaching this as designing a set of gears - you're best off with this approach.
0 -
As said, the final goal is to be able to 3D-print bevel gears, so let's keep things simple

I successfully generated the teeth; how do I tell Onshape to add them to the main part? Do I have to specifically use a boolean operator? I'm using opPattern() to copy the tooth all around...1 -
Ok, here is a working version, which is a complete port of my OpenScad script:
https://cad.onshape.com/documents/9b04fb889def400dfd4a693f/v/7e4070a95d663f4afeb156f3/e/786005a281331572a0efe88b
Next step will be to use a better profile, and correct little mis-alignements.
0 -
Nice work Sir, and thanks for sharing.
Could we trouble you for options of shaft diameters and woodruff key slots?
Happy coding,
OwS.
Edited for speeling and addition of "key"
Business Systems and Configuration Controller
HWM-Water Ltd0 -
What is woodruff slots? Keyway, as in the Spur Gear script?0
-
Business Systems and Configuration Controller
HWM-Water Ltd0 -
Very cool example of the power of featurescript, @fma, thanks for sharing!
Certainly learned a thing or two reading through the code."A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools." - Douglas Adams, Mostly Harmless0 -
Well, my code is certainly not the best! I have an issue with an extrude REMOVE:
https://cad.onshape.com/documents/9b04fb889def400dfd4a693f/v/dd7d70b022551e8a30474897/e/786005a281331572a0efe88b
In this snapshot, the shaft hole is done between all entities, so it makes a hole in another part:
Line 318, I tried to set the defaultScope param to false, and give the booleanScope param, but doing that, I get a INVALID_INPUT...
Any help welcome.0 -
No: it now says EXTRUDE_NO_SELECTED_REGION...0
-
0
-
Thanks, it works! Queries are the most tricky part of FeatureScript...0
-
Done in release 1.2.owen_sparks said:
Could we trouble you for options of shaft diameters and woodruff key slots?0 -
Wow, thanks.fma said:
Done in release 1.2.owen_sparks said:
Could we trouble you for options of shaft diameters and woodruff key slots?
Owen S.
Business Systems and Configuration Controller
HWM-Water Ltd0 -
As I wrote in the header, there are some little issues, and the gears may not regenerate in all cases; I didn't add any checks on params...
Also note that the ends of the teeth are flat, so don't match the bore, which is circular.
As said, this is mainly for 3D-printing, so it is OK. And I guess it is enough for design visualisation too.0 -
Great plugin, only needed simple bevel gears for my project to 3d print. Only other admins I found were either paid or crappy.
Good work!1 -
hi team. any ideas why all extrudes stop working once I drop the gears? (the green button to apply the extrude is graded out without any errors/ warnings displayed - also the preview shows the operation exactly as expected, I just can't commit it)
0










