FEM: mesh region, add command to FreeCAD GUI menu and tool bar

This commit is contained in:
Bernd Hahnebach 2016-12-20 18:11:13 +01:00 committed by Yorik van Havre
parent 36868f3fe5
commit 347d4be25f
6 changed files with 75 additions and 0 deletions

View File

@ -70,6 +70,7 @@ SET(FemScripts_SRCS
_CommandMechanicalMaterial.py
_CommandMeshGmshFromShape.py
_CommandMeshNetgenFromShape.py
_CommandMeshRegion.py
_CommandPurgeResults.py
_CommandRunSolver.py
_CommandShellThickness.py

View File

@ -51,6 +51,7 @@ INSTALL(
FemMeshRegion.py
_FemMeshRegion.py
_ViewProviderFemMeshRegion.py
_CommandMeshRegion.py
FemBeamSection.py
_FemBeamSection.py

View File

@ -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"):

View File

@ -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"

View File

@ -52,6 +52,7 @@ class FemWorkbench (Workbench):
import _CommandFEMMesh2Mesh
import _CommandMeshGmshFromShape
import _CommandMeshNetgenFromShape
import _CommandMeshRegion
import _CommandAnalysis
import _CommandShellThickness
import _CommandBeamSection

View File

@ -0,0 +1,57 @@
# ***************************************************************************
# * *
# * Copyright (c) 2016 - Bernd Hahnebach <bernd@bimstatik.org> *
# * *
# * 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())