By writing a custom script to handle this you are circumventing the regular post methods that handle the tools and WCS, please be careful and check all gcode before running it on your machine.Inventthis wrote: Do you know how to add that to the post processor script?
Thanks
Tools and tool controllers are stored independently of the operations but operations have a reference to the selected tool. You can access the tool controller and tool data using op.ToolController or a helper: PathUtil.toolControllerForOp(op).
One way to combine the operations and the correct tool controllers would be loop through the operations and check if the tool is the same as the currently selected tool, if its not add the tool to a list to be processed followed by the operation, for example:
Code: Select all
import PathScripts.PathUtil as PathUtil
from PathScripts.post import linuxcnc_post as pp
objsToPost = []
currTool = None
for op in job.Operations.Group:
tc = PathUtil.toolControllerForOp(op)
if tc is not None and PathUtil.opProperty(op, 'Active'):
if tc.ToolNumber != currTool:
objsToPost.append(tc)
print("post tool:", tc.Name)
currTool = tc.ToolNumber
objsToPost.append(op)
print("post op:", op.Name)
pp.export(objsToPost, 'C:/Documents/FreeCAD-Gcode/outputFile.cnc', '')
Thanks,
Dan