Fem: Update old ElementGeometry*D with new properties

This commit is contained in:
marioalexis
2025-09-02 17:49:15 -03:00
committed by Chris Hennes
parent 5a02a99643
commit cab5f4d85a
2 changed files with 28 additions and 13 deletions

View File

@@ -189,6 +189,8 @@ class ElementGeometry1D(base_femelement.BaseFemElement):
def onDocumentRestored(self, obj):
# update old project with new properties
super().onDocumentRestored(obj)
for prop in self._get_properties():
try:
obj.getPropertyByName(prop.name)

View File

@@ -30,6 +30,7 @@ __url__ = "https://www.freecad.org"
# \brief element geometry 2D object
from . import base_femelement
from .base_fempythonobject import _PropHelper
class ElementGeometry2D(base_femelement.BaseFemElement):
@@ -42,18 +43,30 @@ class ElementGeometry2D(base_femelement.BaseFemElement):
def __init__(self, obj):
super().__init__(obj)
obj.addProperty(
"App::PropertyLength",
"Thickness",
"ShellThickness",
"set thickness of the shell elements",
)
obj.setPropertyStatus("Thickness", "LockDynamic")
def _get_properties(self):
prop = super()._get_properties()
obj.addProperty(
"App::PropertyFloat",
"Offset",
"ShellThickness",
"set thickness offset of the shell elements",
prop.append(
_PropHelper(
type="App::PropertyLength",
name="Thickness",
group="ShellThickness",
doc="Set thickness of the shell elements",
value="0 mm",
)
)
obj.Offset = 0.0
prop.append(
_PropHelper(
type="App::PropertyFloat",
name="Offset",
group="ShellThickness",
doc="Set thickness offset of the shell elements",
value=0.0,
)
)
return prop
def onDocumentRestored(self, obj):
# update old project with new properties
super().onDocumentRestored(obj)