FEM: FEMMesh2Mesh, only make the tool active on selection of a femmesh or a femmesh and a result
This commit is contained in:
parent
04287d7aa3
commit
3e4cf998d7
|
@ -58,6 +58,10 @@ class FemCommands(object):
|
|||
active = FemGui.getActiveAnalysis() is not None and self.active_analysis_in_active_doc() and self.results_present()
|
||||
elif self.is_active == 'with_part_feature':
|
||||
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_femmesh_andor_res':
|
||||
active = FreeCADGui.ActiveDocument is not None and self.with_femmesh_andor_res_selected()
|
||||
elif self.is_active == 'with_material':
|
||||
active = FemGui.getActiveAnalysis() is not None and self.active_analysis_in_active_doc() and self.material_selected()
|
||||
elif self.is_active == 'with_solver':
|
||||
|
@ -81,6 +85,13 @@ class FemCommands(object):
|
|||
else:
|
||||
return False
|
||||
|
||||
def femmesh_selected(self):
|
||||
sel = FreeCADGui.Selection.getSelection()
|
||||
if len(sel) == 1 and sel[0].isDerivedFrom("Fem::FemMeshObject"):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def material_selected(self):
|
||||
sel = FreeCADGui.Selection.getSelection()
|
||||
if len(sel) == 1 and sel[0].isDerivedFrom("App::MaterialObjectPython"):
|
||||
|
@ -88,6 +99,26 @@ class FemCommands(object):
|
|||
else:
|
||||
return False
|
||||
|
||||
def with_femmesh_andor_res_selected(self):
|
||||
sel = FreeCADGui.Selection.getSelection()
|
||||
if len(sel) == 1 and sel[0].isDerivedFrom("Fem::FemMeshObject"):
|
||||
return True
|
||||
elif len(sel) == 2:
|
||||
if(sel[0].isDerivedFrom("Fem::FemMeshObject")):
|
||||
if(sel[1].isDerivedFrom("Fem::FemResultObject")):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
elif(sel[1].isDerivedFrom("Fem::FemMeshObject")):
|
||||
if(sel[0].isDerivedFrom("Fem::FemResultObject")):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
|
||||
def active_analysis_in_active_doc(self):
|
||||
return FemGui.getActiveAnalysis().Document is FreeCAD.ActiveDocument
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ class _CommandFemMesh2Mesh(FemCommands):
|
|||
self.resources = {'Pixmap': 'fem-fem-mesh-from-shape',
|
||||
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_FemMesh2Mesh", "FEM mesh to mesh"),
|
||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_FemMesh2Mesh", "Convert the surface of a FEM mesh to a mesh")}
|
||||
self.is_active = 'with_document'
|
||||
self.is_active = 'with_femmesh_andor_res'
|
||||
|
||||
def Activated(self):
|
||||
FreeCAD.ActiveDocument.openTransaction("Create FEM mesh")
|
||||
|
|
Loading…
Reference in New Issue
Block a user