Skip to content

Commit

Permalink
Path: Drilling checks for bit size to determine drillability
Browse files Browse the repository at this point in the history
  • Loading branch information
sliptonic authored and yorikvanhavre committed Mar 21, 2017
1 parent ffc4fb2 commit 8a3ac33
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 21 deletions.
39 changes: 22 additions & 17 deletions src/Mod/Path/PathScripts/PathDrilling.py
Expand Up @@ -35,8 +35,8 @@


LOG_MODULE = 'PathDrilling'
PathLog.setLevel(PathLog.Level.INFO, LOG_MODULE)
#PathLog.trackModule('PathDrilling')
PathLog.setLevel(PathLog.Level.DEBUG, LOG_MODULE)
PathLog.trackModule('PathDrilling')

FreeCADGui = None
if FreeCAD.GuiUp:
Expand All @@ -61,7 +61,7 @@ def __init__(self, obj):
# Base & location
obj.addProperty("App::PropertyLinkSubList", "Base","Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "The base geometry of this toolpath"))
#obj.addProperty("App::PropertyVectorList", "Positions", "Tag", QtCore.QT_TRANSLATE_NOOP("PathDressup_HoldingTags", "Locations of insterted holding tags"))
obj.addProperty("App::PropertyIntegerList", "Disabled", "Tag", QtCore.QT_TRANSLATE_NOOP("PathDressup_HoldingTags", "Ids of disabled holding tags"))
obj.addProperty("App::PropertyIntegerList", "Disabled", "Path", QtCore.QT_TRANSLATE_NOOP("PathDressup_HoldingTags", "Ids of disabled holding tags"))

# General Properties
obj.addProperty("App::PropertyBool", "Active", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","Make False, to prevent operation from generating code"))
Expand Down Expand Up @@ -128,7 +128,7 @@ def execute(self, obj):
baseobject = parentJob.Base
if baseobject is None:
return
holes = self.findHoles(baseobject.Shape)
holes = self.findHoles(obj, baseobject.Shape)
for hole in holes:
self.addDrillableLocation(obj, baseobject, hole[0])

Expand Down Expand Up @@ -198,25 +198,30 @@ def execute(self, obj):
obj.Path = path
obj.ViewObject.Visibility = False

def findHoles(self, obj):
PathLog.track()
def findHoles(self, obj, shape):
import DraftGeomUtils as dgu
PathLog.track('obj: {} shape: {}'.format(obj, shape))
holelist = []
if obj.BoundBox.ZLength == 0:
for i in range(len(obj.Edges)):
tooldiameter = obj.ToolController.Proxy.getTool(obj.ToolController).Diameter
PathLog.debug('search for holes larger than tooldiameter: {}: '.format(tooldiameter))
if dgu.isPlanar(shape):
for i in range(len(shape.Edges)):
candidateEdgeName = "Edge" + str(i +1)
e = obj.getElement(candidateEdgeName)
if PathUtils.isDrillable(obj, e):
x = e.BoundBox.Center.x
y = e.BoundBox.Center.y
e = shape.getElement(candidateEdgeName)
if PathUtils.isDrillable(shape, e, tooldiameter):
PathLog.debug('edge candidate: {} is drillable '.format(e))
x = e.Curve.Center.x
y = e.Curve.Center.y
diameter = e.BoundBox.XLength
holelist.append((candidateEdgeName, e, x, y, diameter))
else:
for i in range(len(obj.Faces)):
for i in range(len(shape.Faces)):
candidateFaceName = "Face" + str(i + 1)
f = obj.getElement(candidateFaceName)
if PathUtils.isDrillable(obj, f):
x = f.BoundBox.Center.x
y = f.BoundBox.Center.y
f = shape.getElement(candidateFaceName)
if PathUtils.isDrillable(obj, f, tooldiameter):
PathLog.debug('face candidate: {} is drillable '.format(f))
x = f.Surface.Center.x
y = f.Surface.Center.y
diameter = f.BoundBox.XLength
holelist.append((candidateFaceName, f, x, y, diameter))

Expand Down
15 changes: 11 additions & 4 deletions src/Mod/Path/PathScripts/PathUtils.py
Expand Up @@ -84,8 +84,8 @@ def curvetowire(obj, steps):
p0 = p
return edgelist

def isDrillable(obj, candidate):
PathLog.debug('obj: {} candidate {}')
def isDrillable(obj, candidate, tooldiameter=None):
PathLog.track('obj: {} candidate: {} tooldiameter {}'.format(obj, candidate, tooldiameter))
drillable = False
if candidate.ShapeType == 'Face':
face = candidate
Expand All @@ -107,7 +107,10 @@ def isDrillable(obj, candidate):
elif not hasattr(face.Surface, "Radius"): #abs(face.BoundBox.XLength - face.BoundBox.YLength) > 0.05:
drillable = False
else:
drillable = True
if tooldiameter is not None:
drillable = face.Surface.Radius >= tooldiameter/2
else:
drillable = True
else:
for edge in candidate.Edges:
if isinstance(edge.Curve, Part.Circle) and edge.isClosed():
Expand All @@ -117,7 +120,11 @@ def isDrillable(obj, candidate):
drillable = False
else:
PathLog.debug("Has Radius, Circle")
drillable = True
if tooldiameter is not None:
drillable = edge.Curve.Radius >= tooldiameter/2
else:
drillable = True
PathLog.debug("candidate is drillable: {}".format(drillable))
return drillable

# fixme set at 4 decimal places for testing
Expand Down

0 comments on commit 8a3ac33

Please sign in to comment.