Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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.
Why doesn't the spur gear feature script update properly when using a variable studio

When you create a variable studio and add variables like gear pitch and teeth number, and then create gears in a part studio based on those variables, the gear outputs correctly. But if you go back and edit the variable amount in the Var studio and go back to the part studio, it generates wrong. The variable names are still present in the feature script box but the Gear diameter is acting like a driving dimension and causes issues with the change and tooth profile. Since gear design is always a function of 2 of the 3 factors (pitch, T#, or diameter) I think any of the gear design feature scripts need to have the option to choose which 2 of 3 are the driving dimension and which is driven.
Tagged:
0
Answers
There is a genuine problem here, and I think I've figured it out.
The editGearLogic() editing logic function works by comparing the previous value in the definition to the new value and updates things if it changed. However, when the value in the definition is a variable, the previous value and the new value are both the current value of the variable and so are the same, even if the value of that variable has changed. This means variable changes never trigger the editGearLogic() updates, but these updates are important for ensuring the module, diametralPitch, circularPitch and pitchCircleDiameter are all set consistently with each other.
I'm going to fix this…
It's not just that the editGearLogic() editing logic function can't see the changes when it was a changed variable value, it's also that the whole function is not triggered for variable changes, only for changes done in the UI. Interestingly I can watch the module value change in the open Spur Gear UI dialog when I change the `#Module" variable I've set it to, but I can see the pitchCircleDiameter in the UI dialog not changing, even when I've changed the editGearLogic() function to always recalculate pitchCircleDiameter.
I think a big part of the problem is there are interdependent settings in the
definition
that the UI dialog drives, and it's relying on theeditGearLogic()
function to change them so they are consistent. In particular, changing any one of themodule
,diametralPitch
,circularPitch
, orpitchCircleDiameter
values will recalculate the others, and changingnumTeeth
will also changepitchCircleDiameter
. But using variables in any of these means they can change without the others being updated.It's not so bad for
module
,diametralPitch
, andcircularPitch
,because they are different ways of specifying the same thing and only one is displayed selected by theGearInputType
setting, so you don't really see when they get out of sync. Unfortunately, the current featurescript version only uses themodule
value and relies on it being set correctly byeditGearLogic()
. This means if you configure your gear using a variable to setdiametralPitch
and you change that variable, the change is not applied becausemodule
is not updated. You can only use a variable to setmodule
and have it mostly work.But the big visible problem is
pitchCircleDiameter
which doesn't get updated, which means although your module change from changing the variable is applied, the gear diameter is not changed, and things get pretty messy.I'm going to fix this.