Skip to content

Commit

Permalink
cycloide gear: dw -> pitch_diameter
Browse files Browse the repository at this point in the history
  • Loading branch information
looooo committed Jan 3, 2025
1 parent f7c8080 commit 3707c27
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions freecad/gears/cycloidgear.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,25 @@ def __init__(self, obj):
obj.root_fillet = 0
obj.Proxy = self

def onDocumentRestored(self, obj):
"""
backward compatibility functions
"""
if hasattr(obj, "dw"):
pitch_diameter = getattr(obj, "dw")
obj.addProperty(
"App::PropertyLength",
"pitch_diameter",
"computed",
QT_TRANSLATE_NOOP("App::Property", "The pitch diameter."),
1,
)
obj.pitch_diameter = pitch_diameter
obj.removeProperty("dw")
obj.setExpression(
"angular_backlash", "backlash / pitch_diameter * 360° / pi"
)

def add_helical_properties(self, obj):
obj.addProperty(
"App::PropertyBool",
Expand Down Expand Up @@ -174,15 +193,15 @@ def add_cycloid_properties(self, obj):
def add_computed_properties(self, obj):
obj.addProperty(
"App::PropertyLength",
"dw",
"pitch_diameter",
"computed",
QT_TRANSLATE_NOOP("App::Property", "The pitch diameter."),
)
obj.setExpression(
"dw", "num_teeth * module"
"pitch_diameter", "num_teeth * module"
) # calculate via expression to ease usage for placement
obj.setEditorMode(
"dw", 1
"pitch_diameter", 1
) # set read-only after setting the expression, else it won't be visible. bug?
obj.addProperty(
"App::PropertyAngle",
Expand All @@ -194,7 +213,7 @@ def add_computed_properties(self, obj):
),
)
obj.setExpression(
"angular_backlash", "backlash / dw * 360° / pi"
"angular_backlash", "backlash / pitch_diameter * 360° / pi"
) # calculate via expression to ease usage for placement
obj.setEditorMode(
"angular_backlash", 1
Expand All @@ -203,7 +222,7 @@ def add_computed_properties(self, obj):
def generate_gear_shape(self, fp):
fp.gear.num_teeth = fp.num_teeth
fp.gear.m = fp.module.Value
fp.dw = fp.module * fp.num_teeth
fp.pitch_diameter = fp.module * fp.num_teeth
fp.gear.num_teeth_1 = fp.inner_diameter
fp.gear.num_teeth_2 = fp.outer_diameter
fp.gear.clearance = fp.clearance
Expand Down

0 comments on commit 3707c27

Please sign in to comment.