Fixed pylint warnings for PathUtil family
This commit is contained in:
@@ -104,7 +104,7 @@ There is currently a bug that invalidates the DAG if an object
|
||||
is deleted that still has one or more expressions attached to it.
|
||||
Use this function to remove all expressions before deletion.'''
|
||||
if hasattr(obj, 'ExpressionEngine'):
|
||||
for attr,expr in obj.ExpressionEngine:
|
||||
for attr, expr in obj.ExpressionEngine: # pylint: disable=unused-variable
|
||||
obj.setExpression(attr, None)
|
||||
|
||||
def toUnicode(string):
|
||||
|
||||
@@ -72,57 +72,6 @@ def waiting_effects(function):
|
||||
return new_function
|
||||
|
||||
|
||||
def cleanedges(splines, precision):
|
||||
'''cleanedges([splines],precision). Convert BSpline curves, Beziers, to arcs that can be used for cnc paths.
|
||||
Returns Lines as is. Filters Circle and Arcs for over 180 degrees. Discretizes Ellipses. Ignores other geometry. '''
|
||||
PathLog.track()
|
||||
edges = []
|
||||
for spline in splines:
|
||||
if geomType(spline) == "BSplineCurve":
|
||||
arcs = spline.Curve.toBiArcs(precision)
|
||||
for i in arcs:
|
||||
edges.append(Part.Edge(i))
|
||||
|
||||
elif geomType(spline) == "BezierCurve":
|
||||
newspline = spline.Curve.toBSpline()
|
||||
arcs = newspline.toBiArcs(precision)
|
||||
for i in arcs:
|
||||
edges.append(Part.Edge(i))
|
||||
|
||||
elif geomType(spline) == "Ellipse":
|
||||
edges = curvetowire(spline, 1.0) # fixme hardcoded value
|
||||
|
||||
elif geomType(spline) == "Circle":
|
||||
arcs = filterArcs(spline)
|
||||
for i in arcs:
|
||||
edges.append(Part.Edge(i))
|
||||
|
||||
elif geomType(spline) == "Line":
|
||||
edges.append(spline)
|
||||
|
||||
elif geomType(spline) == "LineSegment":
|
||||
edges.append(spline)
|
||||
|
||||
else:
|
||||
pass
|
||||
|
||||
return edges
|
||||
|
||||
|
||||
def curvetowire(obj, steps):
|
||||
'''adapted from DraftGeomUtils, because the discretize function changed a bit '''
|
||||
|
||||
PathLog.track()
|
||||
points = obj.copy().discretize(Distance=eval('steps'))
|
||||
p0 = points[0]
|
||||
edgelist = []
|
||||
for p in points[1:]:
|
||||
edge = Part.makeLine((p0.x, p0.y, p0.z), (p.x, p.y, p.z))
|
||||
edgelist.append(edge)
|
||||
p0 = p
|
||||
return edgelist
|
||||
|
||||
|
||||
def isDrillable(obj, candidate, tooldiameter=None, includePartials=False):
|
||||
"""
|
||||
Checks candidates to see if they can be drilled.
|
||||
@@ -201,7 +150,7 @@ def isDrillable(obj, candidate, tooldiameter=None, includePartials=False):
|
||||
else:
|
||||
drillable = True
|
||||
PathLog.debug("candidate is drillable: {}".format(drillable))
|
||||
except Exception as ex:
|
||||
except Exception as ex: # pylint: disable=broad-except
|
||||
PathLog.warning(translate("PathUtils", "Issue determine drillability: {}").format(ex))
|
||||
return drillable
|
||||
|
||||
@@ -408,7 +357,7 @@ def getToolControllers(obj):
|
||||
'''returns all the tool controllers'''
|
||||
try:
|
||||
job = findParentJob(obj)
|
||||
except Exception:
|
||||
except Exception: # pylint: disable=broad-except
|
||||
job = None
|
||||
|
||||
if job:
|
||||
@@ -509,7 +458,6 @@ def rapid(x=None, y=None, z=None):
|
||||
|
||||
def feed(x=None, y=None, z=None, horizFeed=0, vertFeed=0):
|
||||
""" Return gcode string to perform a linear feed."""
|
||||
global feedxy
|
||||
retstr = "G01 F"
|
||||
if(x is None) and (y is None):
|
||||
retstr += str("%.4f" % horizFeed)
|
||||
@@ -579,9 +527,8 @@ def helicalPlunge(plungePos, rampangle, destZ, startZ, toold, plungeR, horizFeed
|
||||
# toold = self.radius * 2
|
||||
|
||||
helixCmds = "(START HELICAL PLUNGE)\n"
|
||||
if(plungePos is None):
|
||||
if plungePos is None:
|
||||
raise Exception("Helical plunging requires a position!")
|
||||
return None
|
||||
|
||||
helixX = plungePos.x + toold / 2 * plungeR
|
||||
helixY = plungePos.y
|
||||
@@ -630,12 +577,10 @@ def rampPlunge(edge, rampangle, destZ, startZ):
|
||||
rampCmds = "(START RAMP PLUNGE)\n"
|
||||
if(edge is None):
|
||||
raise Exception("Ramp plunging requires an edge!")
|
||||
return None
|
||||
|
||||
sPoint = edge.Vertexes[0].Point
|
||||
ePoint = edge.Vertexes[1].Point
|
||||
# Evidently edges can get flipped- pick the right one in this case
|
||||
# FIXME: This is iffy code, based on what already existed in the "for vpos ..." loop below
|
||||
if ePoint == sPoint:
|
||||
# print "FLIP"
|
||||
ePoint = edge.Vertexes[-1].Point
|
||||
@@ -647,7 +592,6 @@ def rampPlunge(edge, rampangle, destZ, startZ):
|
||||
rampCmds += rapid(z=startZ)
|
||||
|
||||
# Ramp down to the requested depth
|
||||
# FIXME: This might be an arc, so handle that as well
|
||||
|
||||
curZ = max(startZ - rampDZ, destZ)
|
||||
done = False
|
||||
@@ -667,11 +611,13 @@ def rampPlunge(edge, rampangle, destZ, startZ):
|
||||
return rampCmds
|
||||
|
||||
|
||||
def sort_jobs(locations, keys, attractors=[]):
|
||||
def sort_jobs(locations, keys, attractors=None):
|
||||
""" sort holes by the nearest neighbor method
|
||||
keys: two-element list of keys for X and Y coordinates. for example ['x','y']
|
||||
originally written by m0n5t3r for PathHelix
|
||||
"""
|
||||
if attractors is None:
|
||||
attractors = []
|
||||
try:
|
||||
from queue import PriorityQueue
|
||||
except ImportError:
|
||||
@@ -703,7 +649,7 @@ def sort_jobs(locations, keys, attractors=[]):
|
||||
# prevent dictionary comparison by inserting the index
|
||||
q.put((dist(j, location) + weight(j), i, j))
|
||||
|
||||
prio, i, result = q.get()
|
||||
prio, i, result = q.get() # pylint: disable=unused-variable
|
||||
|
||||
return result
|
||||
|
||||
|
||||
Reference in New Issue
Block a user