Update Array/Copy to handle placement correctly

This commit is contained in:
Christian Mesh
2023-03-13 07:49:20 -04:00
parent 85fa6568fd
commit ab3891be09
3 changed files with 11 additions and 6 deletions

View File

@@ -24,7 +24,7 @@ import FreeCAD
import FreeCADGui
import Path
import PathScripts
from PathScripts.PathUtils import applyPlacementToPath
import PathScripts.PathUtils as PathUtils
from Path.Dressup.Utils import toolController
from PySide import QtCore
import math
@@ -349,7 +349,7 @@ class PathArray:
for b in base:
pl = FreeCAD.Placement()
pl.move(pos)
np = Path.Path([cm.transform(pl) for cm in b.Path.Commands])
np = Path.Path([cm.transform(pl) for cm in PathUtils.getPathWithPlacement(b).Commands])
output += np.toGCode()
elif self.arrayType == "Linear2D":
@@ -376,7 +376,7 @@ class PathArray:
if not (i == 0 and j == 0):
pl.move(pos)
np = Path.Path(
[cm.transform(pl) for cm in b.Path.Commands]
[cm.transform(pl) for cm in PathUtils.getPathWithPlacement(b).Commands]
)
output += np.toGCode()
else:
@@ -402,7 +402,7 @@ class PathArray:
if not (i == 0 and j == 0):
pl.move(pos)
np = Path.Path(
[cm.transform(pl) for cm in b.Path.Commands]
[cm.transform(pl) for cm in PathUtils.getPathWithPlacement(b).Commands]
)
output += np.toGCode()
# Eif
@@ -415,7 +415,7 @@ class PathArray:
pl = FreeCAD.Placement()
pl.rotate(self.centre, FreeCAD.Vector(0, 0, 1), ang)
np = applyPlacementToPath(pl, b.Path)
np = PathUtils.applyPlacementToPath(pl, PathUtils.getPathWithPlacement(b))
output += np.toGCode()
# return output

View File

@@ -63,6 +63,8 @@ class ObjectPathCopy:
obj.ToolController = obj.Base.ToolController
if obj.Base.Path:
obj.Path = obj.Base.Path.copy()
if obj.Base.Placement:
obj.Placement = obj.Base.Placement
class ViewProviderPathCopy:

View File

@@ -68,10 +68,13 @@ class CommandPathSimpleCopy:
FreeCAD.ActiveDocument.openTransaction("Simple Copy")
FreeCADGui.doCommand(
"srcpath = FreeCADGui.Selection.getSelectionEx()[0].Object.Path\n"
"srcobj = FreeCADGui.Selection.getSelectionEx()[0].Object\n"
)
FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.doCommand(
"srcpath = PathScripts.PathUtils.getPathWithPlacement(srcobj)\n"
)
FreeCADGui.addModule("Path.Op.Custom")
FreeCADGui.doCommand(
'obj = Path.Op.Custom.Create("' + selection[0].Name + '_SimpleCopy")'