[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot]
2025-03-23 22:43:52 +00:00
parent 2bca01f0cf
commit f072bde2d0
5 changed files with 51 additions and 82 deletions

View File

@@ -42,6 +42,7 @@ class TestEngrave:
return True
return False
class TestFeature:
def __init__(self):
self.Path = Path.Path()
@@ -60,15 +61,9 @@ class TestDressupArray(PathTestBase):
def test00(self):
"""Verify array with zero copies provides original path."""
source_gcode = (
"G0 X0 Y0 Z0\n"
"G1 X10 Y10 Z0\n"
)
expected_gcode = (
"G0 X0.000000 Y0.000000 Z0.000000\n"
"G1 X10.000000 Y10.000000 Z0.000000\n"
)
source_gcode = "G0 X0 Y0 Z0\n" "G1 X10 Y10 Z0\n"
expected_gcode = "G0 X0.000000 Y0.000000 Z0.000000\n" "G1 X10.000000 Y10.000000 Z0.000000\n"
base = TestEngrave(source_gcode)
obj = TestFeature()
@@ -79,17 +74,13 @@ class TestDressupArray(PathTestBase):
def test01(self):
"""Verify linear x/y/z 1D array with 1 copy."""
source_gcode = (
"G0 X0 Y0 Z0\n"
"G1 X10 Y10 Z0\n"
)
expected_gcode = (
"G0 X0.000000 Y0.000000 Z0.000000\n"
"G1 X10.000000 Y10.000000 Z0.000000\n"
source_gcode = "G0 X0 Y0 Z0\n" "G1 X10 Y10 Z0\n"
"G0 X12.000000 Y12.000000 Z5.000000\n"
"G1 X22.000000 Y22.000000 Z5.000000\n"
expected_gcode = (
"G0 X0.000000 Y0.000000 Z0.000000\n"
"G1 X10.000000 Y10.000000 Z0.000000\n"
"G0 X12.000000 Y12.000000 Z5.000000\n"
"G1 X22.000000 Y22.000000 Z5.000000\n"
)
base = TestEngrave(source_gcode)
@@ -104,29 +95,21 @@ class TestDressupArray(PathTestBase):
def test01(self):
"""Verify linear x/y/z 2D array."""
source_gcode = (
"G0 X0 Y0 Z0\n"
"G1 X10 Y10 Z0\n"
)
source_gcode = "G0 X0 Y0 Z0\n" "G1 X10 Y10 Z0\n"
expected_gcode = (
"G0 X0.000000 Y0.000000 Z0.000000\n"
"G1 X10.000000 Y10.000000 Z0.000000\n"
"G0 X0.000000 Y6.000000 Z0.000000\n"
"G1 X10.000000 Y16.000000 Z0.000000\n"
"G0 X12.000000 Y6.000000 Z0.000000\n"
"G1 X22.000000 Y16.000000 Z0.000000\n"
"G0 X12.000000 Y0.000000 Z0.000000\n"
"G1 X22.000000 Y10.000000 Z0.000000\n"
"G0 X24.000000 Y0.000000 Z0.000000\n"
"G1 X34.000000 Y10.000000 Z0.000000\n"
"G0 X24.000000 Y6.000000 Z0.000000\n"
"G1 X34.000000 Y16.000000 Z0.000000\n"
"G0 X0.000000 Y0.000000 Z0.000000\n"
"G1 X10.000000 Y10.000000 Z0.000000\n"
"G0 X0.000000 Y6.000000 Z0.000000\n"
"G1 X10.000000 Y16.000000 Z0.000000\n"
"G0 X12.000000 Y6.000000 Z0.000000\n"
"G1 X22.000000 Y16.000000 Z0.000000\n"
"G0 X12.000000 Y0.000000 Z0.000000\n"
"G1 X22.000000 Y10.000000 Z0.000000\n"
"G0 X24.000000 Y0.000000 Z0.000000\n"
"G1 X34.000000 Y10.000000 Z0.000000\n"
"G0 X24.000000 Y6.000000 Z0.000000\n"
"G1 X34.000000 Y16.000000 Z0.000000\n"
)
base = TestEngrave(source_gcode)
@@ -141,10 +124,3 @@ class TestDressupArray(PathTestBase):
da.execute(obj)
self.assertTrue(obj.Path.toGCode() == expected_gcode, "Incorrect g-code generated")

View File

@@ -115,7 +115,7 @@ class DressupArray(DressupBase):
"Path",
QT_TRANSLATE_NOOP("App::Property", "Seed value for jitter randomness"),
)
self.obj = obj
obj.Base = base
@@ -179,12 +179,8 @@ class DressupArray(DressupBase):
return True
def dressupExecute(self, obj):
if (
not obj.Base
or not obj.Base.isDerivedFrom("Path::Feature")
or not obj.Base.Path
):
if not obj.Base or not obj.Base.isDerivedFrom("Path::Feature") or not obj.Base.Path:
Path.Log.error(translate("PathArray", "Base is empty or an invalid object."))
return None
@@ -312,7 +308,6 @@ class PathArray:
)
pos = self._calculateJitter(pos)
pl = FreeCAD.Placement()
# do not process the index 0,0. It will be processed by the base Paths themselves
if not (i == 0 and j == 0):
@@ -323,7 +318,7 @@ class PathArray:
for cm in PathUtils.getPathWithPlacement(base).Commands
]
)
output+= np.toGCode()
output += np.toGCode()
else:
for i in range(self.copiesX + 1):
for j in range(self.copiesY + 1):
@@ -372,9 +367,7 @@ def Create(base, name="DressupArray"):
"""Create(base, name='DressupPathBoundary') ... creates a dressup array."""
if not base.isDerivedFrom("Path::Feature"):
Path.Log.error(
translate("CAM_DressupArray", "The selected object is not a path") + "\n"
)
Path.Log.error(translate("CAM_DressupArray", "The selected object is not a path") + "\n")
return None
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)

View File

@@ -2,12 +2,13 @@ from PySide.QtCore import QT_TRANSLATE_NOOP
from Path.Op.Base import ObjectOp
class DressupBase:
"""
Base class for all dressups to provide common interface with the rest of CAM
One major example is making sure all dressups export base operation settings
like coolant, tool controller, etc.
"""
"""
def setup_coolant_property(self, obj):
if not hasattr(obj, "CoolantMode"):
@@ -25,14 +26,14 @@ class DressupBase:
def setup_tool_controller_property(self, obj):
if not hasattr(obj, "ToolController"):
obj.addProperty(
"App::PropertyLink",
"ToolController",
"Path",
QT_TRANSLATE_NOOP(
"App::Property",
"The tool controller that will be used to calculate the path",
),
)
"App::PropertyLink",
"ToolController",
"Path",
QT_TRANSLATE_NOOP(
"App::Property",
"The tool controller that will be used to calculate the path",
),
)
def __init__(self, obj, base):
@@ -42,7 +43,7 @@ class DressupBase:
"Base",
QT_TRANSLATE_NOOP("App::Property", "The base path to modify"),
)
obj.addProperty(
"App::PropertyBool",
"Active",
@@ -88,6 +89,3 @@ class DressupBase:
Should be overwritten by subclasses.
"""
pass

View File

@@ -1,5 +1,3 @@
from PySide.QtCore import QT_TRANSLATE_NOOP
import FreeCAD
import Path
@@ -98,6 +96,7 @@ def Create(base, name="DressupPathArray"):
FreeCAD.ActiveDocument.commitTransaction()
return obj
if FreeCAD.GuiUp:
# register the FreeCAD command
FreeCADGui.addCommand("CAM_DressupArray", CommandPathDressupArray())

View File

@@ -210,13 +210,16 @@ class ObjectArray:
QtGui.QMessageBox.warning(
None,
QT_TRANSLATE_NOOP("CAM_ArrayOp", "Operation is depreciated"),
QT_TRANSLATE_NOOP("CAM_ArrayOp",
("CAM -> Path Modification -> Array operation is depreciated "
"and will be removed in future FreeCAD versions.\n\n"
"Please use CAM -> Path Dressup -> Array instead.\n\n"
"DO NOT USE CURRENT ARRAY OPERATION WHEN MACHINING WITH COOLANT!\n"
"Due to a bug - collant will not be enabled for array paths."
)),
QT_TRANSLATE_NOOP(
"CAM_ArrayOp",
(
"CAM -> Path Modification -> Array operation is depreciated "
"and will be removed in future FreeCAD versions.\n\n"
"Please use CAM -> Path Dressup -> Array instead.\n\n"
"DO NOT USE CURRENT ARRAY OPERATION WHEN MACHINING WITH COOLANT!\n"
"Due to a bug - collant will not be enabled for array paths."
),
),
)
# backwards compatibility for PathArrays created before support for multiple bases
if isinstance(obj.Base, list):