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.

Updating Official Feature Scripts and Using the Updated Version

I'm working on a design for compound planetary gear boxes with the intention of 3D printing them: https://cad.onshape.com/documents/9ca554446455ea6f1adca427/v/115c4f54e64515268982634d/e/10697cc92f7ab71e3933066c
I have developed a design using the offical Spur Gear feature script, but that script lacks backlash control, which given the 3D printer manufacturing is problematic.
I know how to change the script to add the backlash feature that I want, but in order to do this I need to make a copy of the script.
Is there a way that I can update my original design so that it uses my copy of the feature script instead of the official version?

Best Answer


  • greg_frost204greg_frost204 Member Posts: 8
    The backlash code is here:
    It is pretty much a straight up copy of the official spur gear with a single new parameters:

    annotation { "Name" : "Backlash" }
            isLength(definition.backlash, BACKLASH_BOUNDS);

                (meter) : [-500, 0.0, 500],
                (centimeter) : 0,
                (millimeter) : 0,
                (inch) : 0
            } as LengthBoundSpec;

    With this change to the involute generation code:

        // involute definition math
                var angle = (t + definition.backlash/definition.pitchCircleDiameter/2)*radian;
    It moves the face of each tooth 1/4 of the specified backlash along the line of the pitch circle.
    This means for instance if you specify 0.2mm as the backlash and you specify this on both gears, you get an additional gap between the coupling teeth of approx 0.2mm.
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 2,886
    There are different types of backlash calculations which may also need to be considered: https://khkgears.net/new/gear_knowledge/gear_technical_reference/gear_backlash.html
  • greg_frost204greg_frost204 Member Posts: 8
    It would be awesome if you could include that in the official script. Also, if you are looking to provide a bevel gear script, you might want to check out this:

  • greg_frost204greg_frost204 Member Posts: 8
    Another suggestion for the spur gear script would be a helix angle parameters (with a check box for double helix).
  • greg_frost204greg_frost204 Member Posts: 8
    edited October 2019
    The backlash implementation that I provided is what the reference you posted calls Circumferential Backlash. You can also get backlash by changing the distance between gear centres, but in that case, the gears will no longer mesh using the proper involute. Normal backlash should be equivalent, where the Normal backlash is equal to the Circumferential Backlash times the cosine of the pressure angle. For a typical pressure angle this is about 10% less than the Circumferential Backlash. The other types of backlash mentioned by that reference seem inappropriate in the modelling context.

    Thanks for that reference too. Some good info there. If you are open to accepting contributions and including them in the official script, I'd be interested in working on the helix change too. At the moment my compound planetary gear uses the feature script to generate the gear, and then uses the gear face to sweep the helix and then delete the original gear. It would be far better to have helix built in. If you have a view on how the helix parameters should be organised, let me know. I was thinking:
    Helical Gear (checkbox)
    Helix Angle (postitive for clockwise, negative for counter clock wise)
    Double Helix (checkbox).

    But another way would be to select clockwise or counter clockwise as selectable options (this seems to be what Helix does).
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 2,886
    So I should code both options or just Normal?
  • greg_frost204greg_frost204 Member Posts: 8
    edited October 2019
    I think from a modelling perspective, you should only code one. Perhaps Normal Backlash would be more intuitive for people who know the fit tolerance of their printers. For Normal Backlash, it would be the same as my implementation, but you would want to divide the adjustment factor by cos(pressure angle).

    Either would allow backlash adjustment, whereas the current script does not. A bit of trial and error is probably required to settle on the right backlash for a given printer in either case.
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 2,886
    @greg_frost204 - I've added all your suggestions and shared you into a doc for testing - if you are happy I will publish in the official feature.
  • greg_frost204greg_frost204 Member Posts: 8
    edited October 2019
    That is brilliant! I have had a play and it seems to work perfectly. The development of the helix feature was a nice surprise.
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 2,886
    Excellent.  I’ll post it tomorrow. 
Sign In or Register to comment.