From e3348e7eee192a4d3b1f57fe3bafe2d4e66cb44d Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Thu, 5 Oct 2017 05:59:06 +0100 Subject: [PATCH] FEM: nonlinear material command, only allow to add nonlinear material to solid material --- src/Mod/Fem/PyGui/FemCommands.py | 9 +++++++++ .../Fem/PyGui/_CommandFemMaterialMechanicalNonlinear.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Mod/Fem/PyGui/FemCommands.py b/src/Mod/Fem/PyGui/FemCommands.py index 91b05e0313..1322851d2d 100644 --- a/src/Mod/Fem/PyGui/FemCommands.py +++ b/src/Mod/Fem/PyGui/FemCommands.py @@ -68,6 +68,8 @@ class FemCommands(object): active = FreeCADGui.ActiveDocument is not None and self.with_femmesh_andor_res_selected() elif self.is_active == 'with_material': active = FemGui.getActiveAnalysis() is not None and self.active_analysis_in_active_doc() and self.material_selected() + elif self.is_active == 'with_material_solid': + active = FemGui.getActiveAnalysis() is not None and self.active_analysis_in_active_doc() and self.material_solid_selected() elif self.is_active == 'with_solver': active = FemGui.getActiveAnalysis() is not None and self.active_analysis_in_active_doc() and self.solver_selected() elif self.is_active == 'with_analysis_without_solver': @@ -123,6 +125,13 @@ class FemCommands(object): else: return False + def material_solid_selected(self): + sel = FreeCADGui.Selection.getSelection() + if len(sel) == 1 and sel[0].isDerivedFrom("App::MaterialObjectPython") and hasattr(sel[0], "Category") and sel[0].Category == "Solid": + return True + else: + return False + def with_femmesh_andor_res_selected(self): sel = FreeCADGui.Selection.getSelection() if len(sel) == 1 and sel[0].isDerivedFrom("Fem::FemMeshObject"): diff --git a/src/Mod/Fem/PyGui/_CommandFemMaterialMechanicalNonlinear.py b/src/Mod/Fem/PyGui/_CommandFemMaterialMechanicalNonlinear.py index 86d191cafd..27e8dfea08 100644 --- a/src/Mod/Fem/PyGui/_CommandFemMaterialMechanicalNonlinear.py +++ b/src/Mod/Fem/PyGui/_CommandFemMaterialMechanicalNonlinear.py @@ -42,7 +42,7 @@ class _CommandFemMaterialMechanicalNonlinear(FemCommands): 'MenuText': QtCore.QT_TRANSLATE_NOOP("FEM_MaterialMechanicalNonlinear", "Nonlinear mechanical material"), 'Accel': "C, W", 'ToolTip': QtCore.QT_TRANSLATE_NOOP("FEM_MaterialMechanicalNonlinear", "Creates a nonlinear mechanical material")} - self.is_active = 'with_material' + self.is_active = 'with_material_solid' def Activated(self): sel = FreeCADGui.Selection.getSelection()