diff --git a/src/Mod/Fem/App/CMakeLists.txt b/src/Mod/Fem/App/CMakeLists.txt index 14633a173..3393c593c 100755 --- a/src/Mod/Fem/App/CMakeLists.txt +++ b/src/Mod/Fem/App/CMakeLists.txt @@ -70,6 +70,7 @@ SET(FemScripts_SRCS _CommandMechanicalMaterial.py _CommandMeshGmshFromShape.py _CommandMeshNetgenFromShape.py + _CommandMeshRegion.py _CommandPurgeResults.py _CommandRunSolver.py _CommandShellThickness.py diff --git a/src/Mod/Fem/CMakeLists.txt b/src/Mod/Fem/CMakeLists.txt index d54181750..e00dd5fa4 100755 --- a/src/Mod/Fem/CMakeLists.txt +++ b/src/Mod/Fem/CMakeLists.txt @@ -51,6 +51,7 @@ INSTALL( FemMeshRegion.py _FemMeshRegion.py _ViewProviderFemMeshRegion.py + _CommandMeshRegion.py FemBeamSection.py _FemBeamSection.py diff --git a/src/Mod/Fem/FemCommands.py b/src/Mod/Fem/FemCommands.py index 7c6f505d1..79284e756 100644 --- a/src/Mod/Fem/FemCommands.py +++ b/src/Mod/Fem/FemCommands.py @@ -60,6 +60,8 @@ class FemCommands(object): active = FreeCADGui.ActiveDocument is not None and self.part_feature_selected() elif self.is_active == 'with_femmesh': active = FreeCADGui.ActiveDocument is not None and self.femmesh_selected() + elif self.is_active == 'with_gmsh_femmesh': + active = FreeCADGui.ActiveDocument is not None and self.gmsh_femmesh_selected() elif self.is_active == 'with_femmesh_andor_res': active = FreeCADGui.ActiveDocument is not None and self.with_femmesh_andor_res_selected() elif self.is_active == 'with_material': @@ -92,6 +94,13 @@ class FemCommands(object): else: return False + def gmsh_femmesh_selected(self): + sel = FreeCADGui.Selection.getSelection() + if len(sel) == 1 and hasattr(sel[0], "Proxy") and sel[0].Proxy.Type == "FemMeshGmsh": + return True + else: + return False + def material_selected(self): sel = FreeCADGui.Selection.getSelection() if len(sel) == 1 and sel[0].isDerivedFrom("App::MaterialObjectPython"): diff --git a/src/Mod/Fem/Gui/Workbench.cpp b/src/Mod/Fem/Gui/Workbench.cpp index 01f0ef790..1038afa47 100755 --- a/src/Mod/Fem/Gui/Workbench.cpp +++ b/src/Mod/Fem/Gui/Workbench.cpp @@ -59,8 +59,11 @@ Gui::ToolBarItem* Workbench::setupToolBars() const << "Fem_Analysis" << "Fem_SolverCalculix" // << "Fem_SolverZ88" + << "Separator" << "Fem_MeshNetgenFromShape" << "Fem_MeshGmshFromShape" + << "Fem_MeshRegion" + << "Separator" << "Fem_MechanicalMaterial" << "Fem_MaterialMechanicalNonlinear" << "Fem_BeamSection" @@ -129,8 +132,11 @@ Gui::MenuItem* Workbench::setupMenuBar() const << "Fem_Analysis" << "Fem_SolverCalculix" << "Fem_SolverZ88" + << "Separator" << "Fem_MeshNetgenFromShape" << "Fem_MeshGmshFromShape" + << "Fem_MeshRegion" + << "Separator" << "Fem_MechanicalMaterial" << "Fem_MaterialMechanicalNonlinear" << "Fem_BeamSection" diff --git a/src/Mod/Fem/InitGui.py b/src/Mod/Fem/InitGui.py index d813bd4a4..65985a2f2 100644 --- a/src/Mod/Fem/InitGui.py +++ b/src/Mod/Fem/InitGui.py @@ -52,6 +52,7 @@ class FemWorkbench (Workbench): import _CommandFEMMesh2Mesh import _CommandMeshGmshFromShape import _CommandMeshNetgenFromShape + import _CommandMeshRegion import _CommandAnalysis import _CommandShellThickness import _CommandBeamSection diff --git a/src/Mod/Fem/_CommandMeshRegion.py b/src/Mod/Fem/_CommandMeshRegion.py new file mode 100644 index 000000000..8cd8e87d4 --- /dev/null +++ b/src/Mod/Fem/_CommandMeshRegion.py @@ -0,0 +1,57 @@ +# *************************************************************************** +# * * +# * Copyright (c) 2016 - Bernd Hahnebach * +# * * +# * This program is free software; you can redistribute it and/or modify * +# * it under the terms of the GNU Lesser General Public License (LGPL) * +# * as published by the Free Software Foundation; either version 2 of * +# * the License, or (at your option) any later version. * +# * for detail see the LICENCE text file. * +# * * +# * This program is distributed in the hope that it will be useful, * +# * but WITHOUT ANY WARRANTY; without even the implied warranty of * +# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# * GNU Library General Public License for more details. * +# * * +# * You should have received a copy of the GNU Library General Public * +# * License along with this program; if not, write to the Free Software * +# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +# * USA * +# * * +# *************************************************************************** + +__title__ = "_CommandMeshRegion" +__author__ = "Bernd Hahnebach" +__url__ = "http://www.freecadweb.org" + +## @package CommandMeshRegion +# \ingroup FEM + +import FreeCAD +from FemCommands import FemCommands +import FreeCADGui +from PySide import QtCore + + +class _CommandMeshRegion(FemCommands): + "The Fem_MeshRegion command definition" + def __init__(self): + super(_CommandMeshRegion, self).__init__() + self.resources = {'Pixmap': 'fem-femmesh-from-shape', + 'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_MeshRegion", "FEM mesh region"), + 'Accel': "M, R", + 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_MeshRegion", "Creates a FEM mesh region")} + self.is_active = 'with_gmsh_femmesh' + + def Activated(self): + FreeCAD.ActiveDocument.openTransaction("Create FemMeshRegion") + FreeCADGui.addModule("FemMeshRegion") + sel = FreeCADGui.Selection.getSelection() + if (len(sel) == 1): + sobj = sel[0] + if len(sel) == 1 and hasattr(sobj, "Proxy") and sobj.Proxy.Type == "FemMeshGmsh": + FreeCADGui.doCommand("FemMeshRegion.makeFemMeshRegion(App.ActiveDocument." + sobj.Name + ")") + + FreeCADGui.Selection.clearSelection() + +FreeCADGui.addCommand('Fem_MeshRegion', _CommandMeshRegion())