FEM: Move _CommandFemFromShape class to separate file

Signed-off-by: Przemo Firszt <przemo@firszt.eu>
This commit is contained in:
Przemo Firszt
2015-10-09 20:10:12 +01:00
committed by wmayer
parent dfb2335421
commit cf8ef4d9bc
5 changed files with 37 additions and 27 deletions

View File

@@ -0,0 +1,34 @@
import FreeCAD
if FreeCAD.GuiUp:
import FreeCADGui
from PySide import QtCore
class _CommandFemFromShape:
def GetResources(self):
return {'Pixmap': 'fem-fem-mesh-from-shape',
'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
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Fem_CreateFromShape', _CommandFemFromShape())