FEM: Migrate _CommandFemFromShape to FemCommands and add new is_active type
Signed-off-by: Przemo Firszt <przemo@firszt.eu>
This commit is contained in:
parent
217103affb
commit
1ad481b435
|
@ -54,6 +54,8 @@ class FemCommands(object):
|
|||
active = FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None
|
||||
elif self.is_active == 'with_results':
|
||||
active = FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None and self.results_present()
|
||||
elif self.is_active == 'with_part_feature':
|
||||
active = FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None and self.part_feature_selected()
|
||||
return active
|
||||
|
||||
def results_present(self):
|
||||
|
@ -63,3 +65,10 @@ class FemCommands(object):
|
|||
if o.isDerivedFrom('Fem::FemResultObject'):
|
||||
results = True
|
||||
return results
|
||||
|
||||
def part_feature_selected(self):
|
||||
sel = FreeCADGui.Selection.getSelection()
|
||||
if len(sel) == 1 and sel[0].isDerivedFrom("Part::Feature"):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
|
|
@ -25,17 +25,20 @@ __author__ = "Juergen Riegel"
|
|||
__url__ = "http://www.freecadweb.org"
|
||||
|
||||
import FreeCAD
|
||||
from FemCommands import FemCommands
|
||||
|
||||
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")}
|
||||
class _CommandFemFromShape(FemCommands):
|
||||
def __init__(self):
|
||||
super(_CommandFemFromShape, self).__init__()
|
||||
self.resources = {'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")}
|
||||
self.is_active = 'with_part_feature'
|
||||
|
||||
def Activated(self):
|
||||
FreeCAD.ActiveDocument.openTransaction("Create FEM mesh")
|
||||
|
@ -50,11 +53,6 @@ class _CommandFemFromShape:
|
|||
|
||||
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())
|
||||
|
|
Loading…
Reference in New Issue
Block a user