Skip to content

Commit

Permalink
FEM: FEMMesh2Mesh, only make the tool active on selection of a femmes…
Browse files Browse the repository at this point in the history
…h or a femmesh and a result
  • Loading branch information
berndhahnebach committed Nov 25, 2016
1 parent 04287d7 commit 3e4cf99
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
31 changes: 31 additions & 0 deletions src/Mod/Fem/FemCommands.py
Expand Up @@ -58,6 +58,10 @@ def IsActive(self):
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':
Expand All @@ -81,13 +85,40 @@ def part_feature_selected(self):
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"):
return True
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

Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Fem/_CommandFEMMesh2Mesh.py
Expand Up @@ -41,7 +41,7 @@ def __init__(self):
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")
Expand Down

0 comments on commit 3e4cf99

Please sign in to comment.