Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

Bevel gear pair generator

fmafma 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.

Comments

  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,211
    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 Inc
  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,211
    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 Inc
  • fmafma Member Posts: 87 ✭✭
    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?
  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,211
    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 Inc
  • fmafma Member Posts: 87 ✭✭
    Ok, thanks. I'm working on the teeth, and I will refactor the code once I get something working.
  • robert_morrisrobert_morris OS Professional, Developers Posts: 168 PRO
    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.
  • fmafma Member Posts: 87 ✭✭
    Very interesting! Thanks for pointing.
  • PeteYodisPeteYodis Moderator, Onshape Employees Posts: 541
    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.




  • fmafma Member Posts: 87 ✭✭
    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...
  • fmafma Member Posts: 87 ✭✭
    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.
  • owen_sparksowen_sparks Member, Developers Posts: 2,660 PRO
    edited March 2017
    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 Ltd
  • fmafma Member Posts: 87 ✭✭
    What is woodruff slots? Keyway, as in the Spur Gear script?
  • owen_sparksowen_sparks Member, Developers Posts: 2,660 PRO
    Hi @fma, I should have stated Woodruff "Key" slot.

    Along these lines:-


    Regards, Owen S.
    Business Systems and Configuration Controller
    HWM-Water Ltd
  • leon_pootleon_poot Member, Developers Posts: 87 ✭✭✭
    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 Harmless
  • fmafma Member Posts: 87 ✭✭
    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.
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,681
    @fma very cool - if you swapped your skPolyline for skSpline would it work?
    Senior Director, Technical Services, EMEAI
  • fmafma Member Posts: 87 ✭✭
    No: it now says EXTRUDE_NO_SELECTED_REGION...
  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    @fma You'll want the scope to be
    qCreatedBy(id + "revolve1", EntityType.BODY)

  • fmafma Member Posts: 87 ✭✭
    Thanks, it works! Queries are the most tricky part of FeatureScript...
  • fmafma Member Posts: 87 ✭✭

    Could we trouble you for options of shaft diameters and woodruff key slots?

    Done in release 1.2.
  • owen_sparksowen_sparks Member, Developers Posts: 2,660 PRO
    fma said:

    Could we trouble you for options of shaft diameters and woodruff key slots?

    Done in release 1.2.
    Wow, thanks. 
    Owen S.
    Business Systems and Configuration Controller
    HWM-Water Ltd
  • fmafma Member Posts: 87 ✭✭
    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.
  • leo_chen538leo_chen538 Member Posts: 2
    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!
  • peter_m091peter_m091 Member Posts: 8
    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)
Sign In or Register to comment.