Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEM: prevent python added properties to be removed #13687

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Mod/Fem/femobjects/base_fempythonobject.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ***************************************************************************

Check warning on line 1 in src/Mod/Fem/femobjects/base_fempythonobject.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

would reformat src/Mod/Fem/femobjects/base_fempythonobject.py

Check warning on line 1 in src/Mod/Fem/femobjects/base_fempythonobject.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Missing module docstring (missing-module-docstring)
# * Copyright (c) 2017 Markus Hovorka <m.hovorka@live.de> *
# * Copyright (c) 2020 Bernd Hahnebach <bernd@bimstatik.org> *
# * *
Expand Down Expand Up @@ -31,7 +31,7 @@
# \brief base object for FEM Python Features


class BaseFemPythonObject(object):

Check warning on line 34 in src/Mod/Fem/femobjects/base_fempythonobject.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Missing class docstring (missing-class-docstring)

Check warning on line 34 in src/Mod/Fem/femobjects/base_fempythonobject.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Class 'BaseFemPythonObject' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance)

BaseType = "Fem::BaseFemPythonObject"

Expand All @@ -45,7 +45,7 @@
def dumps(self):
return None

def loads(self, state):

Check warning on line 48 in src/Mod/Fem/femobjects/base_fempythonobject.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Unused argument 'state' (unused-argument)
return None


Expand All @@ -62,4 +62,5 @@

def add_to_object(self, obj):
obj.addProperty(**self.info)
obj.setPropertyStatus(self.name, "LockDynamic")
setattr(obj, self.name, self.value)
1 change: 1 addition & 0 deletions src/Mod/Fem/femobjects/constant_vacuumpermittivity.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ***************************************************************************

Check warning on line 1 in src/Mod/Fem/femobjects/constant_vacuumpermittivity.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

would reformat src/Mod/Fem/femobjects/constant_vacuumpermittivity.py

Check warning on line 1 in src/Mod/Fem/femobjects/constant_vacuumpermittivity.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Missing module docstring (missing-module-docstring)
# * Copyright (c) 2020 Bernd Hahnebach <bernd@bimstatik.org> *
# * *
# * This file is part of the FreeCAD CAx development system. *
Expand Down Expand Up @@ -35,18 +35,19 @@
from . import base_fempythonobject


class ConstantVacuumPermittivity(base_fempythonobject.BaseFemPythonObject):

Check warning on line 38 in src/Mod/Fem/femobjects/constant_vacuumpermittivity.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Missing class docstring (missing-class-docstring)

Type = "Fem::ConstantVacuumPermittivity"

def __init__(self, obj):
super(ConstantVacuumPermittivity, self).__init__(obj)

Check warning on line 43 in src/Mod/Fem/femobjects/constant_vacuumpermittivity.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Consider using Python 3 style super() without arguments (super-with-arguments)
obj.addProperty(
"App::PropertyVacuumPermittivity",
"VacuumPermittivity",
"Constants",
"Overwrites default permittivity of vacuum"
)
obj.setPropertyStatus("VacuumPermittivity", "LockDynamic")
# we must set an expression so that the small value can actually be entered
permittivity = Units.Quantity(constants.vacuum_permittivity()).getValueAs("F/m")
obj.setExpression("VacuumPermittivity", str(permittivity))
1 change: 1 addition & 0 deletions src/Mod/Fem/femobjects/constraint_bodyheatsource.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ***************************************************************************

Check warning on line 1 in src/Mod/Fem/femobjects/constraint_bodyheatsource.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

would reformat src/Mod/Fem/femobjects/constraint_bodyheatsource.py

Check warning on line 1 in src/Mod/Fem/femobjects/constraint_bodyheatsource.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Missing module docstring (missing-module-docstring)
# * Copyright (c) 2017 Markus Hovorka <m.hovorka@live.de> *
# * Copyright (c) 2020 Bernd Hahnebach <bernd@bimstatik.org> *
# * *
Expand Down Expand Up @@ -33,12 +33,12 @@
from . import base_fempythonobject


class ConstraintBodyHeatSource(base_fempythonobject.BaseFemPythonObject):

Check warning on line 36 in src/Mod/Fem/femobjects/constraint_bodyheatsource.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Missing class docstring (missing-class-docstring)

Type = "Fem::ConstraintBodyHeatSource"

def __init__(self, obj):
super(ConstraintBodyHeatSource, self).__init__(obj)

Check warning on line 41 in src/Mod/Fem/femobjects/constraint_bodyheatsource.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Consider using Python 3 style super() without arguments (super-with-arguments)
self.add_properties(obj)

def onDocumentRestored(self, obj):
Expand All @@ -52,4 +52,5 @@
"Base",
"Body heat source"
)
obj.setPropertyStatus("HeatSource", "LockDynamic")
obj.HeatSource = 0.0
2 changes: 2 additions & 0 deletions src/Mod/Fem/femobjects/constraint_centrif.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ***************************************************************************

Check warning on line 1 in src/Mod/Fem/femobjects/constraint_centrif.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

would reformat src/Mod/Fem/femobjects/constraint_centrif.py
# * Copyright (c) 2021 Bernd Hahnebach <bernd@bimstatik.org> *
# * *
# * This file is part of the FreeCAD CAx development system. *
Expand Down Expand Up @@ -48,10 +48,12 @@
"Constraint CENTRIF",
"set rotation frequency f<sub>rot"
)
obj.setPropertyStatus("RotationFrequency", "LockDynamic")

obj.addProperty(
"App::PropertyLinkSubList",
"RotationAxis",
"Constraint CENTRIF",
"set line as axis of rotation"
)
obj.setPropertyStatus("RotationAxis", "LockDynamic")
12 changes: 12 additions & 0 deletions src/Mod/Fem/femobjects/constraint_currentdensity.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ***************************************************************************

Check warning on line 1 in src/Mod/Fem/femobjects/constraint_currentdensity.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

would reformat src/Mod/Fem/femobjects/constraint_currentdensity.py
# * Copyright (c) 2023 Uwe Stöhr <uwestoehr@lyx.org> *
# * *
# * This file is part of the FreeCAD CAx development system. *
Expand Down Expand Up @@ -51,6 +51,7 @@
"Vector Potential",
"Real part of current density x-component"
)
obj.setPropertyStatus("CurrentDensity_re_1", "LockDynamic")
obj.CurrentDensity_re_1 = "0 A/m^2"
if not hasattr(obj, "CurrentDensity_re_2"):
obj.addProperty(
Expand All @@ -59,6 +60,7 @@
"Vector Potential",
"Real part of current density y-component"
)
obj.setPropertyStatus("CurrentDensity_re_2", "LockDynamic")
obj.CurrentDensity_re_2 = "0 A/m^2"
if not hasattr(obj, "CurrentDensity_re_3"):
obj.addProperty(
Expand All @@ -67,6 +69,7 @@
"Vector Potential",
"Real part of current density z-component"
)
obj.setPropertyStatus("CurrentDensity_re_3", "LockDynamic")
obj.CurrentDensity_re_3 = "0 A/m^2"
if not hasattr(obj, "CurrentDensity_im_1"):
obj.addProperty(
Expand All @@ -75,6 +78,7 @@
"Vector Potential",
"Imaginary part of current density x-component"
)
obj.setPropertyStatus("CurrentDensity_im_1", "LockDynamic")
obj.CurrentDensity_im_1 = "0 A/m^2"
if not hasattr(obj, "CurrentDensity_im_2"):
obj.addProperty(
Expand All @@ -83,6 +87,7 @@
"Vector Potential",
"Imaginary part of current density y-component"
)
obj.setPropertyStatus("CurrentDensity_im_2", "LockDynamic")
obj.CurrentDensity_im_2 = "0 A/m^2"
if not hasattr(obj, "CurrentDensity_im_3"):
obj.addProperty(
Expand All @@ -91,6 +96,7 @@
"Vector Potential",
"Imaginary part of current density z-component"
)
obj.setPropertyStatus("CurrentDensity_im_3", "LockDynamic")
obj.CurrentDensity_im_3 = "0 A/m^2"

# now the enable bools
Expand All @@ -101,6 +107,7 @@
"Vector Potential",
""
)
obj.setPropertyStatus("CurrentDensity_re_1_Disabled", "LockDynamic")
obj.CurrentDensity_re_1_Disabled = True
if not hasattr(obj, "CurrentDensity_re_2_Disabled"):
obj.addProperty(
Expand All @@ -109,6 +116,7 @@
"Vector Potential",
""
)
obj.setPropertyStatus("CurrentDensity_re_2_Disabled", "LockDynamic")
obj.CurrentDensity_re_2_Disabled = True
if not hasattr(obj, "CurrentDensity_re_3_Disabled"):
obj.addProperty(
Expand All @@ -117,6 +125,7 @@
"Vector Potential",
""
)
obj.setPropertyStatus("CurrentDensity_re_3_Disabled", "LockDynamic")
obj.CurrentDensity_re_3_Disabled = True
if not hasattr(obj, "CurrentDensity_im_1_Disabled"):
obj.addProperty(
Expand All @@ -125,6 +134,7 @@
"Vector Potential",
""
)
obj.setPropertyStatus("CurrentDensity_im_1_Disabled", "LockDynamic")
obj.CurrentDensity_im_1_Disabled = True
if not hasattr(obj, "CurrentDensity_im_2_Disabled"):
obj.addProperty(
Expand All @@ -133,6 +143,7 @@
"Vector Potential",
""
)
obj.setPropertyStatus("CurrentDensity_im_2_Disabled", "LockDynamic")
obj.CurrentDensity_im_2_Disabled = True
if not hasattr(obj, "CurrentDensity_im_3_Disabled"):
obj.addProperty(
Expand All @@ -141,4 +152,5 @@
"Vector Potential",
""
)
obj.setPropertyStatus("CurrentDensity_im_3_Disabled", "LockDynamic")
obj.CurrentDensity_im_3_Disabled = True
21 changes: 21 additions & 0 deletions src/Mod/Fem/femobjects/constraint_electrostaticpotential.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ***************************************************************************

Check warning on line 1 in src/Mod/Fem/femobjects/constraint_electrostaticpotential.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

would reformat src/Mod/Fem/femobjects/constraint_electrostaticpotential.py
# * Copyright (c) 2017 Markus Hovorka <m.hovorka@live.de> *
# * Copyright (c) 2020 Bernd Hahnebach <bernd@bimstatik.org> *
# * Copyright (c) 2023 Uwe Stöhr <uwestoehr@lyx.org> *
Expand Down Expand Up @@ -53,6 +53,7 @@
"Parameter",
"Electric Potential"
)
obj.setPropertyStatus("Potential", "LockDynamic")
# setting 1 V assures that the unit does not switch to mV
# and the constraint holds usually Volts
obj.Potential = "1 V"
Expand All @@ -64,6 +65,7 @@
"Vector Potential",
"Real part of potential x-component"
)
obj.setPropertyStatus("AV_re_1", "LockDynamic")
obj.AV_re_1 = "0 V"
if not hasattr(obj, "AV_re_2"):
obj.addProperty(
Expand All @@ -72,6 +74,7 @@
"Vector Potential",
"Real part of potential y-component"
)
obj.setPropertyStatus("AV_re_2", "LockDynamic")
obj.AV_re_2 = "0 V"
if not hasattr(obj, "AV_re_3"):
obj.addProperty(
Expand All @@ -80,6 +83,7 @@
"Vector Potential",
"Real part of potential z-component"
)
obj.setPropertyStatus("AV_re_3", "LockDynamic")
obj.AV_re_3 = "0 V"
if not hasattr(obj, "AV_im"):
obj.addProperty(
Expand All @@ -88,6 +92,7 @@
"Vector Potential",
"Imaginary part of scalar potential"
)
obj.setPropertyStatus("AV_im", "LockDynamic")
obj.AV_im = "0 V"
if not hasattr(obj, "AV_im_1"):
obj.addProperty(
Expand All @@ -96,6 +101,7 @@
"Vector Potential",
"Imaginary part of potential x-component"
)
obj.setPropertyStatus("AV_im_1", "LockDynamic")
obj.AV_im_1 = "0 V"
if not hasattr(obj, "AV_im_2"):
obj.addProperty(
Expand All @@ -104,6 +110,7 @@
"Vector Potential",
"Imaginary part of potential y-component"
)
obj.setPropertyStatus("AV_im_2", "LockDynamic")
obj.AV_im_2 = "0 V"
if not hasattr(obj, "AV_im_3"):
obj.addProperty(
Expand All @@ -112,6 +119,7 @@
"Vector Potential",
"Imaginary part of potential z-component"
)
obj.setPropertyStatus("AV_im_3", "LockDynamic")
obj.AV_im_3 = "0 V"

# now the enable bools
Expand All @@ -122,6 +130,7 @@
"Parameter",
"Potential Enabled"
)
obj.setPropertyStatus("PotentialEnabled", "LockDynamic")
obj.PotentialEnabled = True
if not hasattr(obj, "AV_re_1_Disabled"):
obj.addProperty(
Expand All @@ -130,6 +139,7 @@
"Vector Potential",
""
)
obj.setPropertyStatus("AV_re_1_Disabled", "LockDynamic")
obj.AV_re_1_Disabled = True
if not hasattr(obj, "AV_re_2_Disabled"):
obj.addProperty(
Expand All @@ -138,6 +148,7 @@
"Vector Potential",
""
)
obj.setPropertyStatus("AV_re_2_Disabled", "LockDynamic")
obj.AV_re_2_Disabled = True
if not hasattr(obj, "AV_re_3_Disabled"):
obj.addProperty(
Expand All @@ -146,6 +157,7 @@
"Vector Potential",
""
)
obj.setPropertyStatus("AV_re_3_Disabled", "LockDynamic")
obj.AV_re_3_Disabled = True
if not hasattr(obj, "AV_im_Disabled"):
obj.addProperty(
Expand All @@ -154,6 +166,7 @@
"Vector Potential",
""
)
obj.setPropertyStatus("AV_im_Disabled", "LockDynamic")
obj.AV_im_Disabled = True
if not hasattr(obj, "AV_im_1_Disabled"):
obj.addProperty(
Expand All @@ -162,6 +175,7 @@
"Vector Potential",
""
)
obj.setPropertyStatus("AV_im_1_Disabled", "LockDynamic")
obj.AV_im_1_Disabled = True
if not hasattr(obj, "AV_im_2_Disabled"):
obj.addProperty(
Expand All @@ -170,6 +184,7 @@
"Vector Potential",
""
)
obj.setPropertyStatus("AV_im_2_Disabled", "LockDynamic")
obj.AV_im_2_Disabled = True
if not hasattr(obj, "AV_im_3_Disabled"):
obj.addProperty(
Expand All @@ -178,6 +193,7 @@
"Vector Potential",
""
)
obj.setPropertyStatus("AV_im_3_Disabled", "LockDynamic")
obj.AV_im_3_Disabled = True

if not hasattr(obj, "PotentialConstant"):
Expand All @@ -187,6 +203,7 @@
"Parameter",
"Potential Constant"
)
obj.setPropertyStatus("PotentialConstant", "LockDynamic")
obj.PotentialConstant = False

if not hasattr(obj, "ElectricInfinity"):
Expand All @@ -196,6 +213,7 @@
"Parameter",
"Electric Infinity"
)
obj.setPropertyStatus("ElectricInfinity", "LockDynamic")
obj.ElectricInfinity = False

if not hasattr(obj, "ElectricForcecalculation"):
Expand All @@ -205,6 +223,7 @@
"Parameter",
"Electric Force Calculation"
)
obj.setPropertyStatus("ElectricForcecalculation", "LockDynamic")
obj.ElectricForcecalculation = False

if not hasattr(obj, "CapacitanceBody"):
Expand All @@ -214,6 +233,7 @@
"Parameter",
"Capacitance Body"
)
obj.setPropertyStatus("CapacitanceBody", "LockDynamic")
obj.CapacitanceBody = 0

if not hasattr(obj, "CapacitanceBodyEnabled"):
Expand All @@ -223,4 +243,5 @@
"Parameter",
"Capacitance Body Enabled"
)
obj.setPropertyStatus("CapacitanceBodyEnabled", "LockDynamic")
obj.CapacitanceBodyEnabled = False
13 changes: 13 additions & 0 deletions src/Mod/Fem/femobjects/constraint_flowvelocity.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ***************************************************************************

Check warning on line 1 in src/Mod/Fem/femobjects/constraint_flowvelocity.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

would reformat src/Mod/Fem/femobjects/constraint_flowvelocity.py
# * Copyright (c) 2017 Markus Hovorka <m.hovorka@live.de> *
# * Copyright (c) 2020 Bernd Hahnebach <bernd@bimstatik.org> *
# * Copyright (c) 2023 Uwe Stöhr <uwestoehr@lyx.org> *
Expand Down Expand Up @@ -46,81 +46,94 @@
"Parameter",
"Velocity in x-direction"
)
obj.setPropertyStatus("VelocityX", "LockDynamic")
obj.addProperty(
"App::PropertyString",
"VelocityXFormula",
"Parameter",
"Velocity formula in x-direction"
)
obj.setPropertyStatus("VelocityXFormula", "LockDynamic")
obj.addProperty(
"App::PropertyBool",
"VelocityXUnspecified",
"Parameter",
"Use velocity in x-direction"
)
obj.setPropertyStatus("VelocityXUnspecified", "LockDynamic")
obj.VelocityXUnspecified = True
obj.addProperty(
"App::PropertyBool",
"VelocityXHasFormula",
"Parameter",
"Use formula for velocity in x-direction"
)
obj.setPropertyStatus("VelocityXHasFormula", "LockDynamic")

obj.addProperty(
"App::PropertyVelocity",
"VelocityY",
"Parameter",
"Velocity in y-direction"
)
obj.setPropertyStatus("VelocityY", "LockDynamic")
obj.addProperty(
"App::PropertyString",
"VelocityYFormula",
"Parameter",
"Velocity formula in y-direction"
)
obj.setPropertyStatus("VelocityYFormula", "LockDynamic")
obj.addProperty(
"App::PropertyBool",
"VelocityYUnspecified",
"Parameter",
"Use velocity in y-direction"
)
obj.setPropertyStatus("VelocityYUnspecified", "LockDynamic")
obj.VelocityYUnspecified = True
obj.addProperty(
"App::PropertyBool",
"VelocityYHasFormula",
"Parameter",
"Use formula for velocity in y-direction"
)
obj.setPropertyStatus("VelocityYHasFormula", "LockDynamic")

obj.addProperty(
"App::PropertyVelocity",
"VelocityZ",
"Parameter",
"Velocity in z-direction"
)
obj.setPropertyStatus("VelocityZ", "LockDynamic")
obj.addProperty(
"App::PropertyString",
"VelocityZFormula",
"Parameter",
"Velocity formula in z-direction"
)
obj.setPropertyStatus("VelocityZFormula", "LockDynamic")
obj.addProperty(
"App::PropertyBool",
"VelocityZUnspecified",
"Parameter",
"Use velocity in z-direction"
)
obj.setPropertyStatus("VelocityZUnspecified", "LockDynamic")
obj.VelocityZUnspecified = True
obj.addProperty(
"App::PropertyBool",
"VelocityZHasFormula",
"Parameter",
"Use formula for velocity in z-direction"
)
obj.setPropertyStatus("VelocityZHasFormula", "LockDynamic")

obj.addProperty(
"App::PropertyBool",
"NormalToBoundary",
"Parameter",
"Flow is in normal direction"
)
obj.setPropertyStatus("NormalToBoundary", "LockDynamic")