Remove deprecated code

This commit is contained in:
sliptonic
2022-01-16 13:06:33 -06:00
parent 4d91ea271d
commit b42b689a95

View File

@@ -446,199 +446,6 @@ def addToJob(obj, jobname=None):
return job
def rapid(x=None, y=None, z=None):
"""Returns gcode string to perform a rapid move."""
retstr = "G00"
if (x is not None) or (y is not None) or (z is not None):
if x is not None:
retstr += " X" + str("%.4f" % x)
if y is not None:
retstr += " Y" + str("%.4f" % y)
if z is not None:
retstr += " Z" + str("%.4f" % z)
else:
return ""
return retstr + "\n"
def feed(x=None, y=None, z=None, horizFeed=0, vertFeed=0):
"""Return gcode string to perform a linear feed."""
retstr = "G01 F"
if (x is None) and (y is None):
retstr += str("%.4f" % horizFeed)
else:
retstr += str("%.4f" % vertFeed)
if (x is not None) or (y is not None) or (z is not None):
if x is not None:
retstr += " X" + str("%.4f" % x)
if y is not None:
retstr += " Y" + str("%.4f" % y)
if z is not None:
retstr += " Z" + str("%.4f" % z)
else:
return ""
return retstr + "\n"
def arc(cx, cy, sx, sy, ex, ey, horizFeed=0, ez=None, ccw=False):
"""
Return gcode string to perform an arc.
Assumes XY plane or helix around Z
Don't worry about starting Z- assume that's dealt with elsewhere
If start/end radii aren't within eps, abort.
cx, cy -- arc center coordinates
sx, sy -- arc start coordinates
ex, ey -- arc end coordinates
ez -- ending Z coordinate. None unless helix.
horizFeed -- horiz feed speed
ccw -- arc direction
"""
eps = 0.01
if (
math.sqrt((cx - sx) ** 2 + (cy - sy) ** 2)
- math.sqrt((cx - ex) ** 2 + (cy - ey) ** 2)
) >= eps:
PathLog.error(translate("Path", "Illegal arc: Start and end radii not equal"))
return ""
retstr = ""
if ccw:
retstr += "G03 F" + str(horizFeed)
else:
retstr += "G02 F" + str(horizFeed)
retstr += " X" + str("%.4f" % ex) + " Y" + str("%.4f" % ey)
if ez is not None:
retstr += " Z" + str("%.4f" % ez)
retstr += " I" + str("%.4f" % (cx - sx)) + " J" + str("%.4f" % (cy - sy))
return retstr + "\n"
def helicalPlunge(plungePos, rampangle, destZ, startZ, toold, plungeR, horizFeed):
"""
Return gcode string to perform helical entry move.
plungePos -- vector of the helical entry location
destZ -- the lowest Z position or milling level
startZ -- Starting Z position for helical move
rampangle -- entry angle
toold -- tool diameter
plungeR -- the radius of the entry helix
"""
# toold = self.radius * 2
helixCmds = "(START HELICAL PLUNGE)\n"
if plungePos is None:
raise Exception("Helical plunging requires a position!")
helixX = plungePos.x + toold / 2 * plungeR
helixY = plungePos.y
helixCirc = math.pi * toold * plungeR
dzPerRev = math.sin(rampangle / 180.0 * math.pi) * helixCirc
# Go to the start of the helix position
helixCmds += rapid(helixX, helixY)
helixCmds += rapid(z=startZ)
# Helix as required to get to the requested depth
lastZ = startZ
curZ = max(startZ - dzPerRev, destZ)
done = False
while not done:
done = curZ == destZ
# NOTE: FreeCAD doesn't render this, but at least LinuxCNC considers it valid
# helixCmds += arc(plungePos.x, plungePos.y, helixX, helixY, helixX, helixY, ez = curZ, ccw=True)
# Use two half-helixes; FreeCAD renders that correctly,
# and it fits with the other code breaking up 360-degree arcs
helixCmds += arc(
plungePos.x,
plungePos.y,
helixX,
helixY,
helixX - toold * plungeR,
helixY,
horizFeed,
ez=(curZ + lastZ) / 2.0,
ccw=True,
)
helixCmds += arc(
plungePos.x,
plungePos.y,
helixX - toold * plungeR,
helixY,
helixX,
helixY,
horizFeed,
ez=curZ,
ccw=True,
)
lastZ = curZ
curZ = max(curZ - dzPerRev, destZ)
return helixCmds
def rampPlunge(edge, rampangle, destZ, startZ):
"""
Return gcode string to linearly ramp down to milling level.
edge -- edge to follow
rampangle -- entry angle
destZ -- Final Z depth
startZ -- Starting Z depth
FIXME: This ramps along the first edge, assuming it's long
enough, NOT just wiggling back and forth by ~0.75 * toolD.
Not sure if that's any worse, but it's simpler
I think this should be changed to be limited to a maximum ramp size. Otherwise machine time will get longer than it needs to be.
"""
rampCmds = "(START RAMP PLUNGE)\n"
if edge is None:
raise Exception("Ramp plunging requires an edge!")
sPoint = edge.Vertexes[0].Point
ePoint = edge.Vertexes[1].Point
# Evidently edges can get flipped- pick the right one in this case
if ePoint == sPoint:
# print "FLIP"
ePoint = edge.Vertexes[-1].Point
rampDist = edge.Length
rampDZ = math.sin(rampangle / 180.0 * math.pi) * rampDist
rampCmds += rapid(sPoint.x, sPoint.y)
rampCmds += rapid(z=startZ)
# Ramp down to the requested depth
curZ = max(startZ - rampDZ, destZ)
done = False
while not done:
done = curZ == destZ
# If it's an arc, handle it!
if isinstance(edge.Curve, Part.Circle):
raise Exception("rampPlunge: Screw it, not handling an arc.")
# Straight feed! Easy!
else:
rampCmds += feed(ePoint.x, ePoint.y, curZ)
rampCmds += feed(sPoint.x, sPoint.y)
curZ = max(curZ - rampDZ, destZ)
return rampCmds
def sort_locations(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']