Fem: Use new material editor in Reinforced material task panel - fixes #18692
This commit is contained in:
committed by
Chris Hennes
parent
676c2fe568
commit
f132b12df2
@@ -1,6 +1,7 @@
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2013 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
# * Copyright (c) 2016 Bernd Hahnebach <bernd@bimstatik.org> *
|
||||
# * Copyright (c) 2024 Mario Passaglia <mpassaglia[at]cbc.uba.ar> *
|
||||
# * *
|
||||
# * This file is part of the FreeCAD CAx development system. *
|
||||
# * *
|
||||
@@ -23,14 +24,16 @@
|
||||
# ***************************************************************************
|
||||
|
||||
__title__ = "FreeCAD FEM material document object"
|
||||
__author__ = "Juergen Riegel, Bernd Hahnebach"
|
||||
__author__ = "Juergen Riegel, Bernd Hahnebach, Mario Passaglia"
|
||||
__url__ = "https://www.freecad.org"
|
||||
|
||||
## @package material_common
|
||||
# \ingroup FEM
|
||||
# \brief material common object
|
||||
|
||||
from FreeCAD import Base
|
||||
from FreeCAD import Base, Units
|
||||
import Materials
|
||||
|
||||
from . import base_fempythonobject
|
||||
|
||||
_PropHelper = base_fempythonobject._PropHelper
|
||||
@@ -97,9 +100,42 @@ class MaterialCommon(base_fempythonobject.BaseFemPythonObject):
|
||||
# change References to App::PropertyLinkSubListGlobal
|
||||
prop.handle_change_type(obj, old_type="App::PropertyLinkSubList")
|
||||
|
||||
# try update UUID from Material
|
||||
if not obj.UUID:
|
||||
obj.UUID = self._get_material_uuid(obj.Material)
|
||||
|
||||
if not obj.hasExtension("App::SuppressibleExtensionPython"):
|
||||
obj.addExtension("App::SuppressibleExtensionPython")
|
||||
|
||||
def _get_material_uuid(self, material):
|
||||
if not material:
|
||||
return ""
|
||||
|
||||
material_manager = Materials.MaterialManager()
|
||||
|
||||
for a_mat in material_manager.Materials:
|
||||
unmatched_item = True
|
||||
a_mat_prop = material_manager.getMaterial(a_mat).Properties
|
||||
for it in material:
|
||||
if it in a_mat_prop:
|
||||
# first try to compare quantities
|
||||
try:
|
||||
unmatched_item = Units.Quantity(material[it]) != Units.Quantity(
|
||||
a_mat_prop[it]
|
||||
)
|
||||
except ValueError:
|
||||
# if there is no quantity, compare values directly
|
||||
unmatched_item = material[it] != a_mat_prop[it]
|
||||
|
||||
if unmatched_item:
|
||||
break
|
||||
|
||||
if not unmatched_item:
|
||||
# all material items are found in a_mat
|
||||
return a_mat
|
||||
|
||||
return ""
|
||||
|
||||
"""
|
||||
Some remarks to the category. Not finished, thus to be continued.
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2019 Bernd Hahnebach <bernd@bimstatik.org> *
|
||||
# * Copyright (c) 2024 Mario Passaglia <mpassaglia[at]cbc.uba.ar> *
|
||||
# * *
|
||||
# * This file is part of the FreeCAD CAx development system. *
|
||||
# * *
|
||||
@@ -22,7 +23,7 @@
|
||||
# ***************************************************************************
|
||||
|
||||
__title__ = "FreeCAD FEM reinforced material"
|
||||
__author__ = "Bernd Hahnebach"
|
||||
__author__ = "Bernd Hahnebach, Mario Passaglia"
|
||||
__url__ = "https://www.freecad.org"
|
||||
|
||||
## @package material_reinforced
|
||||
@@ -30,6 +31,7 @@ __url__ = "https://www.freecad.org"
|
||||
# \brief reinforced object
|
||||
|
||||
from . import material_common
|
||||
from .base_fempythonobject import _PropHelper
|
||||
|
||||
|
||||
class MaterialReinforced(material_common.MaterialCommon):
|
||||
@@ -42,10 +44,37 @@ class MaterialReinforced(material_common.MaterialCommon):
|
||||
def __init__(self, obj):
|
||||
super().__init__(obj)
|
||||
|
||||
obj.addProperty(
|
||||
"App::PropertyMap", "Reinforcement", "Composites", "Reinforcement material properties"
|
||||
)
|
||||
obj.setPropertyStatus("Reinforcement", "LockDynamic")
|
||||
|
||||
# overwrite Category enumeration
|
||||
obj.Category = ["Solid"]
|
||||
|
||||
def _get_properties(self):
|
||||
prop = super()._get_properties()
|
||||
|
||||
prop.append(
|
||||
_PropHelper(
|
||||
type="App::PropertyMap",
|
||||
name="Reinforcement",
|
||||
group="Composites",
|
||||
doc="Reinforcement material properties",
|
||||
value={},
|
||||
)
|
||||
)
|
||||
prop.append(
|
||||
_PropHelper(
|
||||
type="App::PropertyString",
|
||||
name="ReinforcementUUID",
|
||||
group="Composites",
|
||||
doc="Reinforcement material UUID",
|
||||
hidden=True,
|
||||
value="",
|
||||
)
|
||||
)
|
||||
|
||||
return prop
|
||||
|
||||
def onDocumentRestored(self, obj):
|
||||
super().onDocumentRestored(obj)
|
||||
|
||||
# try update Reinforcement UUID from Reinforcement
|
||||
if not obj.ReinforcementUUID:
|
||||
obj.ReinforcementUUID = self._get_material_uuid(obj.Reinforcement)
|
||||
|
||||
Reference in New Issue
Block a user