From 09b8d7666f62acf9d51fbad677feab15552ff1a2 Mon Sep 17 00:00:00 2001 From: hasecilu Date: Sat, 16 Nov 2024 17:57:37 -0600 Subject: [PATCH] Apply constraint on the head/root fillets of the gears - Use `App::PropertyFloatConstraint` instead of `App::PropertyFloat` in order to get a smaller set of valid options for the parts. Minimum, maximum, step and default values are set. Previously you could enter negative numbers which were fixed at the time of generating the shape avoiding problems but the properties were not fixed. Now users are not able to enter bad data which leads to a simplification of the sanitization code. Proposed upper limit at 1,000. Users are crazy. --- freecad/gears/cycloidgear.py | 8 ++++---- freecad/gears/cycloidgearrack.py | 8 ++++---- freecad/gears/internalinvolutegear.py | 8 ++++---- freecad/gears/involutegear.py | 8 ++++---- freecad/gears/involutegearrack.py | 8 ++++---- freecad/gears/timinggear_t.py | 8 ++++---- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/freecad/gears/cycloidgear.py b/freecad/gears/cycloidgear.py index bfc8806..782bd74 100644 --- a/freecad/gears/cycloidgear.py +++ b/freecad/gears/cycloidgear.py @@ -110,23 +110,23 @@ class CycloidGear(BaseGear): def add_fillet_properties(self, obj): obj.addProperty( - "App::PropertyFloat", + "App::PropertyFloatConstraint", "head_fillet", "fillets", QT_TRANSLATE_NOOP( "App::Property", "a fillet for the tooth-head, radius = head_fillet x module", ), - ) + ).head_fillet = (0.0, 0.0, 1000.0, 0.01) obj.addProperty( - "App::PropertyFloat", + "App::PropertyFloatConstraint", "root_fillet", "fillets", QT_TRANSLATE_NOOP( "App::Property", "a fillet for the tooth-root, radius = root_fillet x module", ), - ) + ).root_fillet = (0.0, 0.0, 1000.0, 0.01) def add_tolerance_properties(self, obj): obj.addProperty( diff --git a/freecad/gears/cycloidgearrack.py b/freecad/gears/cycloidgearrack.py index 93b8fb6..545222f 100644 --- a/freecad/gears/cycloidgearrack.py +++ b/freecad/gears/cycloidgearrack.py @@ -166,23 +166,23 @@ class CycloidGearRack(BaseGear): def add_fillet_properties(self, obj): obj.addProperty( - "App::PropertyFloat", + "App::PropertyFloatConstraint", "head_fillet", "fillets", QT_TRANSLATE_NOOP( "App::Property", "a fillet for the tooth-head, radius = head_fillet x module", ), - ) + ).head_fillet = (0.0, 0.0, 1000.0, 0.01) obj.addProperty( - "App::PropertyFloat", + "App::PropertyFloatConstraint", "root_fillet", "fillets", QT_TRANSLATE_NOOP( "App::Property", "a fillet for the tooth-root, radius = root_fillet x module", ), - ) + ).root_fillet = (0.0, 0.0, 1000.0, 0.01) def generate_gear_shape(self, obj): numpoints = obj.numpoints diff --git a/freecad/gears/internalinvolutegear.py b/freecad/gears/internalinvolutegear.py index 83e3843..43c0fac 100644 --- a/freecad/gears/internalinvolutegear.py +++ b/freecad/gears/internalinvolutegear.py @@ -175,23 +175,23 @@ class InternalInvoluteGear(BaseGear): def add_fillet_properties(self, obj): obj.addProperty( - "App::PropertyFloat", + "App::PropertyFloatConstraint", "head_fillet", "fillets", QT_TRANSLATE_NOOP( "App::Property", "a fillet for the tooth-head, radius = head_fillet x module", ), - ) + ).head_fillet = (0.0, 0.0, 1000.0, 0.01) obj.addProperty( - "App::PropertyFloat", + "App::PropertyFloatConstraint", "root_fillet", "fillets", QT_TRANSLATE_NOOP( "App::Property", "a fillet for the tooth-root, radius = root_fillet x module", ), - ) + ).root_fillet = (0.0, 0.0, 1000.0, 0.01) def add_tolerance_properties(self, obj): obj.addProperty( diff --git a/freecad/gears/involutegear.py b/freecad/gears/involutegear.py index 59bb6bc..8fc01c5 100644 --- a/freecad/gears/involutegear.py +++ b/freecad/gears/involutegear.py @@ -121,23 +121,23 @@ class InvoluteGear(BaseGear): QT_TRANSLATE_NOOP("App::Property", "undercut"), ) obj.addProperty( - "App::PropertyFloat", + "App::PropertyFloatConstraint", "head_fillet", "fillets", QT_TRANSLATE_NOOP( "App::Property", "a fillet for the tooth-head, radius = head_fillet x module", ), - ) + ).head_fillet = (0.0, 0.0, 1000.0, 0.01) obj.addProperty( - "App::PropertyFloat", + "App::PropertyFloatConstraint", "root_fillet", "fillets", QT_TRANSLATE_NOOP( "App::Property", "a fillet for the tooth-root, radius = root_fillet x module", ), - ) + ).root_fillet = (0.0, 0.0, 1000.0, 0.01) def add_helical_properties(self, obj): obj.addProperty( diff --git a/freecad/gears/involutegearrack.py b/freecad/gears/involutegearrack.py index b385190..cde7168 100644 --- a/freecad/gears/involutegearrack.py +++ b/freecad/gears/involutegearrack.py @@ -162,23 +162,23 @@ class InvoluteGearRack(BaseGear): def add_fillet_properties(self, obj): obj.addProperty( - "App::PropertyFloat", + "App::PropertyFloatConstraint", "head_fillet", "fillets", QT_TRANSLATE_NOOP( "App::Property", "a fillet for the tooth-head, radius = head_fillet x module", ), - ) + ).head_fillet = (0.0, 0.0, 1000.0, 0.01) obj.addProperty( - "App::PropertyFloat", + "App::PropertyFloatConstraint", "root_fillet", "fillets", QT_TRANSLATE_NOOP( "App::Property", "a fillet for the tooth-root, radius = root_fillet x module", ), - ) + ).root_fillet = (0.0, 0.0, 1000.0, 0.01) def generate_gear_shape(self, obj): obj.rack.m = obj.module.Value diff --git a/freecad/gears/timinggear_t.py b/freecad/gears/timinggear_t.py index 9c03c3b..43cff5a 100644 --- a/freecad/gears/timinggear_t.py +++ b/freecad/gears/timinggear_t.py @@ -69,23 +69,23 @@ class TimingGearT(BaseGear): ), ) obj.addProperty( - "App::PropertyFloat", + "App::PropertyFloatConstraint", "head_fillet", "fillets", QT_TRANSLATE_NOOP( "App::Property", "a fillet for the tooth-head, radius = head_fillet x module", ), - ) + ).head_fillet = (0.0, 0.0, 1000.0, 0.01) obj.addProperty( - "App::PropertyFloat", + "App::PropertyFloatConstraint", "root_fillet", "fillets", QT_TRANSLATE_NOOP( "App::Property", "a fillet for the tooth-root, radius = root_fillet x module", ), - ) + ).root_fillet = (0.0, 0.0, 1000.0, 0.01) obj.addProperty( "App::PropertyAngle", "alpha",