From 9e065cdb7f254a664851c6dcb75ced8fa97d71ab Mon Sep 17 00:00:00 2001 From: marioalexis Date: Sat, 28 Feb 2026 07:20:12 -0300 Subject: [PATCH] Fem: Add command to clear mesh groups --- src/Mod/Fem/Gui/Resources/Fem.qrc | 1 + .../Resources/icons/FEM_MeshClearGroups.svg | 243 ++++++++++++++++++ src/Mod/Fem/Gui/Workbench.cpp | 1 + src/Mod/Fem/femcommands/commands.py | 24 ++ 4 files changed, 269 insertions(+) create mode 100644 src/Mod/Fem/Gui/Resources/icons/FEM_MeshClearGroups.svg diff --git a/src/Mod/Fem/Gui/Resources/Fem.qrc b/src/Mod/Fem/Gui/Resources/Fem.qrc index f08d0b2e4c..e8740d2017 100755 --- a/src/Mod/Fem/Gui/Resources/Fem.qrc +++ b/src/Mod/Fem/Gui/Resources/Fem.qrc @@ -60,6 +60,7 @@ icons/FEM_FEMMesh2Mesh.svg icons/FEM_MeshBoundaryLayer.svg icons/FEM_MeshClear.svg + icons/FEM_MeshClearGroups.svg icons/FEM_MeshDisplayInfo.svg icons/FEM_MeshGmshFromShape.svg icons/FEM_MeshGroup.svg diff --git a/src/Mod/Fem/Gui/Resources/icons/FEM_MeshClearGroups.svg b/src/Mod/Fem/Gui/Resources/icons/FEM_MeshClearGroups.svg new file mode 100644 index 0000000000..b57de03b3d --- /dev/null +++ b/src/Mod/Fem/Gui/Resources/icons/FEM_MeshClearGroups.svg @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + [bitacobir] + + + 2020-03-16 + + + + FreeCAD + + + + + + FreeCAD LGPL2+ + + + https://www.gnu.org/copyleft/lesser.html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/Fem/Gui/Workbench.cpp b/src/Mod/Fem/Gui/Workbench.cpp index 1a6045e86a..83b86afb38 100644 --- a/src/Mod/Fem/Gui/Workbench.cpp +++ b/src/Mod/Fem/Gui/Workbench.cpp @@ -89,6 +89,7 @@ void Workbench::setupContextMenu(const char* recipient, Gui::MenuItem* item) con StdWorkbench::setupContextMenu(recipient, item); *item << "Separator" << "FEM_MeshClear" + << "FEM_MeshClearGroups" << "FEM_MeshDisplayInfo"; } diff --git a/src/Mod/Fem/femcommands/commands.py b/src/Mod/Fem/femcommands/commands.py index d337908cb5..be67490ee2 100644 --- a/src/Mod/Fem/femcommands/commands.py +++ b/src/Mod/Fem/femcommands/commands.py @@ -725,6 +725,29 @@ class _MeshClear(CommandManager): FreeCAD.ActiveDocument.recompute() +class _MeshClearGroups(CommandManager): + "The FEM_MeshClearGroups command definition" + + def __init__(self): + super().__init__() + self.menutext = Qt.QT_TRANSLATE_NOOP("FEM_MeshClearGroups", "Clear Mesh Groups") + self.tooltip = Qt.QT_TRANSLATE_NOOP("FEM_MeshClearGroups", "Remove groups from FEM mesh") + self.is_active = "with_femmesh" + + def Activated(self): + FreeCAD.ActiveDocument.openTransaction("ClearGroups FEM mesh") + FreeCADGui.addModule("Fem") + grps = "FreeCAD.ActiveDocument." + self.selobj.Name + ".FemMesh.Groups" + remove_func = "FreeCAD.ActiveDocument." + self.selobj.Name + ".FemMesh.removeGroup" + FreeCADGui.doCommand(f"tuple(map({remove_func}, {grps}))") + FreeCAD.Console.PrintMessage( + f"Groups cleared: Now {self.selobj.Name} has {self.selobj.FemMesh.GroupCount} groups\n" + ) + FreeCAD.ActiveDocument.commitTransaction() + FreeCADGui.Selection.clearSelection() + FreeCAD.ActiveDocument.recompute() + + class _MeshDisplayInfo(CommandManager): "The FEM_MeshDisplayInfo command definition" @@ -1233,6 +1256,7 @@ FreeCADGui.addCommand("FEM_MaterialSolid", _MaterialSolid()) FreeCADGui.addCommand("FEM_FEMMesh2Mesh", _FEMMesh2Mesh()) FreeCADGui.addCommand("FEM_MeshBoundaryLayer", _MeshBoundaryLayer()) FreeCADGui.addCommand("FEM_MeshClear", _MeshClear()) +FreeCADGui.addCommand("FEM_MeshClearGroups", _MeshClearGroups()) FreeCADGui.addCommand("FEM_MeshDisplayInfo", _MeshDisplayInfo()) FreeCADGui.addCommand("FEM_MeshGmshFromShape", _MeshGmshFromShape()) FreeCADGui.addCommand("FEM_MeshGroup", _MeshGroup())