FEM: Move _CommandFemFromShape class to separate file
Signed-off-by: Przemo Firszt <przemo@firszt.eu>
This commit is contained in:
@@ -91,6 +91,7 @@ SET(FemScripts_SRCS
|
||||
_CommandQuickAnalysis.py
|
||||
_CommandPurgeFemResults.py
|
||||
_CommandMechanicalJobControl.py
|
||||
_CommandFemFromShape.py
|
||||
)
|
||||
#SOURCE_GROUP("Scripts" FILES ${FemScripts_SRCS})
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ INSTALL(
|
||||
_CommandQuickAnalysis.py
|
||||
_CommandPurgeFemResults.py
|
||||
_CommandMechanicalJobControl.py
|
||||
_CommandFemFromShape.py
|
||||
DESTINATION
|
||||
Mod/Fem
|
||||
)
|
||||
|
||||
@@ -107,6 +107,7 @@ void FemGuiExport initFemGui()
|
||||
Base::Interpreter().loadModule("_CommandQuickAnalysis");
|
||||
Base::Interpreter().loadModule("_CommandPurgeFemResults");
|
||||
Base::Interpreter().loadModule("_CommandMechanicalJobControl");
|
||||
Base::Interpreter().loadModule("_CommandFemFromShape");
|
||||
Base::Interpreter().loadModule("MechanicalAnalysis");
|
||||
Base::Interpreter().loadModule("MechanicalMaterial");
|
||||
Base::Interpreter().loadModule("FemBeamSection");
|
||||
|
||||
@@ -78,32 +78,5 @@ class _CommandNewMechanicalAnalysis:
|
||||
return FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is None
|
||||
|
||||
|
||||
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_NewMechanicalAnalysis', _CommandNewMechanicalAnalysis())
|
||||
FreeCADGui.addCommand('Fem_CreateFromShape', _CommandFemFromShape())
|
||||
|
||||
34
src/Mod/Fem/_CommandFemFromShape.py
Normal file
34
src/Mod/Fem/_CommandFemFromShape.py
Normal 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())
|
||||
Reference in New Issue
Block a user