Skip to content

Commit

Permalink
Return diameter 0 for invalid holes in order to let the UI initialize…
Browse files Browse the repository at this point in the history
… completely
  • Loading branch information
mlampert committed Jul 15, 2019
1 parent f9e23d2 commit 931aa85
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
22 changes: 14 additions & 8 deletions src/Mod/Path/PathScripts/PathCircularHoleBase.py
Expand Up @@ -134,15 +134,20 @@ def holeDiameter(self, obj, base, sub):
edge = self.getArchPanelEdge(obj, base, sub)
return edge.BoundBox.XLength

shape = base.Shape.getElement(sub)
if shape.ShapeType == 'Vertex':
return 0
try:
shape = base.Shape.getElement(sub)
if shape.ShapeType == 'Vertex':
return 0

if shape.ShapeType == 'Edge' and type(shape.Curve) == Part.Circle:
return shape.Curve.Radius * 2

if shape.ShapeType == 'Edge' and type(shape.Curve) == Part.Circle:
return shape.Curve.Radius * 2
# for all other shapes the diameter is just the dimension in X
return shape.BoundBox.XLength
except Part.OCCError as e:
PathLog.error(e)

# for all other shapes the diameter is just the dimension in X
return shape.BoundBox.XLength
return 0

def holePosition(self, obj, base, sub):
'''holePosition(obj, base, sub) ... returns a Vector for the position defined by the given features.
Expand Down Expand Up @@ -184,7 +189,6 @@ def opExecute(self, obj):
calculated and assigned.
Do not overwrite, implement circularHoleExecute(obj, holes) instead.'''
PathLog.track()
PathLog.debug("\nopExecute() in PathCircularHoleBase.py")

holes = []
baseSubsTuples = []
Expand Down Expand Up @@ -364,6 +368,8 @@ def circularHoleExecute(self, obj, holes):
pass # pylint: disable=unnecessary-pass

def findAllHoles(self, obj):
'''findAllHoles(obj) ... find all holes of all base models and assign as features.'''
PathLog.track()
if not self.getJob(obj):
return
features = []
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Path/PathScripts/PathCircularHoleBaseGui.py
Expand Up @@ -81,7 +81,8 @@ def setFields(self, obj):
item.setData(self.DataObjectSub, sub)
self.form.baseList.setItem(self.form.baseList.rowCount()-1, 0, item)

item = QtGui.QTableWidgetItem("{:.3f}".format(obj.Proxy.holeDiameter(obj, base, sub)))
dia = obj.Proxy.holeDiameter(obj, base, sub)
item = QtGui.QTableWidgetItem("{:.3f}".format(dia))
item.setData(self.DataFeatureName, name)
item.setData(self.DataObject, base)
item.setData(self.DataObjectSub, sub)
Expand Down
10 changes: 6 additions & 4 deletions src/Mod/Path/PathScripts/PathJobGui.py
Expand Up @@ -114,15 +114,17 @@ def __init__(self, vobj):
self.switch = None
self.taskPanel = None
self.vobj = None
self.baseVisibility = None
self.stockVisibility = None
self.baseVisibility = {}
self.stockVisibility = False

def attach(self, vobj):
self.vobj = vobj
self.obj = vobj.Object
self.taskPanel = None
self.baseVisibility = None
self.stockVisibility = None
if not hasattr(self, 'baseVisibility'):
self.baseVisibility = {}
if not hasattr(self, 'stockVisibility'):
self.stockVisibility = False

# setup the axis display at the origin
self.switch = coin.SoSwitch()
Expand Down

0 comments on commit 931aa85

Please sign in to comment.