diff --git a/src/Mod/Fem/femobjects/constraint_electrostaticpotential.py b/src/Mod/Fem/femobjects/constraint_electrostaticpotential.py index caa7fe9402..358a621711 100644 --- a/src/Mod/Fem/femobjects/constraint_electrostaticpotential.py +++ b/src/Mod/Fem/femobjects/constraint_electrostaticpotential.py @@ -39,45 +39,71 @@ class ConstraintElectrostaticPotential(base_fempythonobject.BaseFemPythonObject) def __init__(self, obj): super(ConstraintElectrostaticPotential, self).__init__(obj) - obj.addProperty( - "App::PropertyFloat", - "Potential", - "Parameter", - "Potential" - ), - obj.addProperty( - "App::PropertyBool", - "PotentialEnabled", - "Parameter", - "Potential Enabled" - ), - obj.addProperty( - "App::PropertyBool", - "PotentialConstant", - "Parameter", - "Potential Constant" - ), - obj.addProperty( - "App::PropertyBool", - "ElectricInfinity", - "Parameter", - "Electric Infinity" - ), - obj.addProperty( - "App::PropertyBool", - "ElectricForcecalculation", - "Parameter", - "Electric Force Calculation" - ), - obj.addProperty( - "App::PropertyInteger", - "CapacitanceBody", - "Parameter", - "Capacitance Body" - ), - obj.addProperty( - "App::PropertyBool", - "CapacitanceBodyEnabled", - "Parameter", - "Capacitance Body Enabled" - ) + self.add_properties(obj) + + def onDocumentRestored(self, obj): + self.add_properties(obj) + + def add_properties(self, obj): + if not hasattr(obj, "Potential"): + obj.addProperty( + "App::PropertyFloat", + "Potential", + "Parameter", + "Potential" + ), + obj.Potential = 0.0 + + if not hasattr(obj, "PotentialEnabled"): + obj.addProperty( + "App::PropertyBool", + "PotentialEnabled", + "Parameter", + "Potential Enabled" + ), + obj.PotentialEnabled = False + + if not hasattr(obj, "PotentialConstant"): + obj.addProperty( + "App::PropertyBool", + "PotentialConstant", + "Parameter", + "Potential Constant" + ), + obj.PotentialConstant = False + + if not hasattr(obj, "ElectricInfinity"): + obj.addProperty( + "App::PropertyBool", + "ElectricInfinity", + "Parameter", + "Electric Infinity" + ), + obj.ElectricInfinity = False + + if not hasattr(obj, "ElectricForcecalculation"): + obj.addProperty( + "App::PropertyBool", + "ElectricForcecalculation", + "Parameter", + "Electric Force Calculation" + ), + obj.ElectricForcecalculation = False + + if not hasattr(obj, "CapacitanceBody"): + obj.addProperty( + "App::PropertyInteger", + "CapacitanceBody", + "Parameter", + "Capacitance Body" + ), + obj.CapacitanceBody = 0 + + if not hasattr(obj, "CapacitanceBodyEnabled"): + obj.addProperty( + "App::PropertyBool", + "CapacitanceBodyEnabled", + "Parameter", + "Capacitance Body Enabled" + ) + obj.CapacitanceBodyEnabled = False