CAM: apply precommit

This commit is contained in:
Adrian Insaurralde Avalos
2024-09-03 14:54:36 -04:00
parent 261ef09348
commit a17a3cf6d7
337 changed files with 26842 additions and 25585 deletions

View File

@@ -106,9 +106,7 @@ def loopdetect(obj, edge1, edge2):
candidates.append((wire.hashCode(), wire))
if e.hashCode() == edge2.hashCode():
candidates.append((wire.hashCode(), wire))
loop = set(
[x for x in candidates if candidates.count(x) > 1]
) # return the duplicate item
loop = set([x for x in candidates if candidates.count(x) > 1]) # return the duplicate item
if len(loop) != 1:
return None
loopwire = next(x for x in loop)[1]
@@ -122,8 +120,7 @@ def horizontalEdgeLoop(obj, edge):
loops = [
w
for w in wires
if all(Path.Geom.isHorizontal(e) for e in w.Edges)
and Path.Geom.isHorizontal(Part.Face(w))
if all(Path.Geom.isHorizontal(e) for e in w.Edges) and Path.Geom.isHorizontal(Part.Face(w))
]
if len(loops) == 1:
return loops[0]
@@ -194,16 +191,13 @@ def filterArcs(arcEdge):
else:
arcstpt = arcEdge.valueAt(arcEdge.FirstParameter)
arcmid = arcEdge.valueAt(
(arcEdge.LastParameter - arcEdge.FirstParameter) * 0.5
+ arcEdge.FirstParameter
(arcEdge.LastParameter - arcEdge.FirstParameter) * 0.5 + arcEdge.FirstParameter
)
arcquad1 = arcEdge.valueAt(
(arcEdge.LastParameter - arcEdge.FirstParameter) * 0.25
+ arcEdge.FirstParameter
(arcEdge.LastParameter - arcEdge.FirstParameter) * 0.25 + arcEdge.FirstParameter
) # future midpt for arc1
arcquad2 = arcEdge.valueAt(
(arcEdge.LastParameter - arcEdge.FirstParameter) * 0.75
+ arcEdge.FirstParameter
(arcEdge.LastParameter - arcEdge.FirstParameter) * 0.75 + arcEdge.FirstParameter
) # future midpt for arc2
arcendpt = arcEdge.valueAt(arcEdge.LastParameter)
# reconstruct with 2 arcs
@@ -336,16 +330,11 @@ def getOffsetArea(
def reverseEdge(e):
if DraftGeomUtils.geomType(e) == "Circle":
arcstpt = e.valueAt(e.FirstParameter)
arcmid = e.valueAt(
(e.LastParameter - e.FirstParameter) * 0.5 + e.FirstParameter
)
arcmid = e.valueAt((e.LastParameter - e.FirstParameter) * 0.5 + e.FirstParameter)
arcendpt = e.valueAt(e.LastParameter)
arcofCirc = Part.ArcOfCircle(arcendpt, arcmid, arcstpt)
newedge = arcofCirc.toShape()
elif (
DraftGeomUtils.geomType(e) == "LineSegment"
or DraftGeomUtils.geomType(e) == "Line"
):
elif DraftGeomUtils.geomType(e) == "LineSegment" or DraftGeomUtils.geomType(e) == "Line":
stpt = e.valueAt(e.FirstParameter)
endpt = e.valueAt(e.LastParameter)
newedge = Part.makeLine(endpt, stpt)
@@ -536,9 +525,7 @@ def guessDepths(objshape, subs=None):
elif fbb.ZMax == fbb.ZMin and fbb.ZMax > bb.ZMin: # face/shelf
final = fbb.ZMin
return depth_params(
clearance, safe, start, 1.0, 0.0, final, user_depths=None, equalstep=False
)
return depth_params(clearance, safe, start, 1.0, 0.0, final, user_depths=None, equalstep=False)
def drillTipLength(tool):
@@ -552,8 +539,7 @@ def drillTipLength(tool):
if angle <= 0 or angle >= 180:
Path.Log.error(
translate("Path", "Invalid Cutting Edge Angle %.2f, must be >0° and <=180°")
% angle
translate("Path", "Invalid Cutting Edge Angle %.2f, must be >0° and <=180°") % angle
)
return 0.0
@@ -562,9 +548,7 @@ def drillTipLength(tool):
if length < 0:
Path.Log.error(
translate(
"Path", "Cutting Edge Angle (%.2f) results in negative tool tip length"
)
translate("Path", "Cutting Edge Angle (%.2f) results in negative tool tip length")
% angle
)
return 0.0
@@ -707,13 +691,9 @@ class depth_params(object):
return depths
if equalstep:
depths += self.__equal_steps(
self.__start_depth, depths[-1], self.__step_down
)[1:]
depths += self.__equal_steps(self.__start_depth, depths[-1], self.__step_down)[1:]
else:
depths += self.__fixed_steps(
self.__start_depth, depths[-1], self.__step_down
)[1:]
depths += self.__fixed_steps(self.__start_depth, depths[-1], self.__step_down)[1:]
depths.reverse()
@@ -842,6 +822,7 @@ def RtoIJ(startpoint, command):
return newcommand
def getPathWithPlacement(pathobj):
"""
Applies the rotation, and then position of the obj's Placement
@@ -853,6 +834,7 @@ def getPathWithPlacement(pathobj):
return applyPlacementToPath(pathobj.Placement, pathobj.Path)
def applyPlacementToPath(placement, path):
"""
Applies the rotation, and then position of the placement to path
@@ -871,17 +853,13 @@ def applyPlacementToPath(placement, path):
currY = 0
currZ = 0
for cmd in path.Commands:
if (
(cmd.Name in CmdMoveRapid)
or (cmd.Name in CmdMove)
or (cmd.Name in CmdDrill)
):
if (cmd.Name in CmdMoveRapid) or (cmd.Name in CmdMove) or (cmd.Name in CmdDrill):
params = cmd.Parameters
currX = x = params.get("X", currX)
currY = y = params.get("Y", currY)
currZ = z = params.get("Z", currZ)
x, y, z = placement.Rotation.multVec(FreeCAD.Vector(x, y ,z))
x, y, z = placement.Rotation.multVec(FreeCAD.Vector(x, y, z))
if x != currX:
params.update({"X": x})

View File

@@ -58,9 +58,7 @@ class PathUtilsUserInput(object):
r = form.exec_()
if not r:
return None
return [
i for i in controllers if i.Label == form.uiToolController.currentText()
][0]
return [i for i in controllers if i.Label == form.uiToolController.currentText()][0]
def chooseJob(self, jobs):
job = None