+ FEM: reimplement function to create FEM mesh from shape

This commit is contained in:
wmayer 2015-04-23 23:36:05 +02:00
parent ec96217335
commit 4db69850fb
3 changed files with 29 additions and 1 deletions

View File

@ -591,7 +591,7 @@ void CmdFemCreateNodesSet::activated(int iMsg)
bool CmdFemCreateNodesSet::isActive(void)
{
return true;
return hasActiveDocument();
}
//--------------------------------------------------------------------------------------

View File

@ -79,6 +79,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
root->insertItem(item, fem);
fem->setCommand("&FEM");
*fem << "Fem_NewMechanicalAnalysis"
<< "Fem_CreateFromShape"
<< "Fem_MechanicalMaterial"
<< "Separator"
<< "Fem_CreateNodesSet"

View File

@ -84,6 +84,32 @@ class _CommandNewMechanicalAnalysis:
return FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is None
class _CommandFemFromShape:
def GetResources(self):
return {'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_CreateFromShape", "Create FEM mesh"),
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_CreateFromShape", "Create FEM mesh from shape")}
def Activated(self):
FreeCAD.ActiveDocument.openTransaction("Create FEM mesh")
FreeCADGui.addModule("FemGui")
FreeCADGui.addModule("MechanicalAnalysis")
sel = FreeCADGui.Selection.getSelection()
if (len(sel) == 1):
if(sel[0].isDerivedFrom("Part::Feature")):
FreeCADGui.doCommand("App.activeDocument().addObject('Fem::FemMeshShapeNetgenObject', '" + sel[0].Name + "_Mesh')")
FreeCADGui.doCommand("App.activeDocument().ActiveObject.Shape = App.activeDocument()." + sel[0].Name)
FreeCADGui.doCommand("Gui.activeDocument().setEdit(App.ActiveDocument.ActiveObject.Name)")
FreeCADGui.Selection.clearSelection()
def IsActive(self):
sel = FreeCADGui.Selection.getSelection()
if len(sel) == 1:
return sel[0].isDerivedFrom("Part::Feature")
return False
class _CommandMechanicalJobControl:
"the Fem JobControl command definition"
def GetResources(self):
@ -753,5 +779,6 @@ class _ResultControlTaskPanel:
FreeCADGui.Control.closeDialog()
FreeCADGui.addCommand('Fem_NewMechanicalAnalysis', _CommandNewMechanicalAnalysis())
FreeCADGui.addCommand('Fem_CreateFromShape', _CommandFemFromShape())
FreeCADGui.addCommand('Fem_MechanicalJobControl', _CommandMechanicalJobControl())
FreeCADGui.addCommand('Fem_ShowResult', _CommandMechanicalShowResult())