Skip to content

Commit

Permalink
Fix bug with mesh related commands when no mesh is selected
Browse files Browse the repository at this point in the history
The select_mesh method did not return a tuple on every outcome. So it
failed when nothing was selected.

fixes #25
  • Loading branch information
furti committed Sep 20, 2018
1 parent f04e596 commit e67bf1f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lithophane_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ def findSelectedMesh():
selection = FreeCADGui.Selection.getSelection()

if len(selection) != 1:
return None
return (None, None)

selectedObject = selection[0]

if not hasattr(selectedObject, 'Mesh'):
return None
return (None, None)

return selection[0].Mesh, selection[0].Label
return (selection[0].Mesh, selection[0].Label)

def vectorAtGround(vector):
return FreeCAD.Vector(vector.x, vector.y, 0)
Expand Down
2 changes: 1 addition & 1 deletion measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def GetResources(self):
'Pixmap': iconPath('Measure.svg')}

def Activated(self):
mesh = lithophane_utils.findSelectedMesh()[0]
mesh, label = lithophane_utils.findSelectedMesh()

if mesh is None:
qtutils.showInfo("No Mesh selected", "Select exactly one Mesh to continue")
Expand Down

0 comments on commit e67bf1f

Please sign in to comment.