Scripting Path workbench

Here's the place for discussion related to CAM/CNC and the development of the Path module.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
tcs_ulrich
Posts: 44
Joined: Mon Aug 28, 2017 10:11 am

Scripting Path workbench

Post by tcs_ulrich »

Hi,

I want to generate G-code from an in Script created Object (an Plate with Text as Pocket).
But i find no Documentation how to generate the "Path Operation" and the "Profile based on Faces"

best regards
Christian
tcs_ulrich
Posts: 44
Joined: Mon Aug 28, 2017 10:11 am

Re: Scripting Path workbench

Post by tcs_ulrich »

Hi, in meantime ive get an patially working Solution in this German Thread: https://forum.freecadweb.org/viewtopic. ... 45#p378645

But i have at time no working Solution to Create an Tool definition and Assign Tools to Path Operations, has anyone an clue how that can be done in an python script ?
etrombly
Posts: 144
Joined: Thu Dec 05, 2019 6:50 pm

Re: Scripting Path workbench

Post by etrombly »

This is how I create a PathCustom and assign it to a job and toolcontroller. You should be able to modify it to do what you need.

Code: Select all

obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "Custom")
    PathScripts.PathCustom.ObjectCustom(obj)
    obj.ViewObject.Proxy = 0
    obj.Gcode = gcode
    PathScripts.PathUtils.addToJob(obj)
    obj.ToolController = PathScripts.PathUtils.findToolController(obj)
edit: This just assigns the first active tool. Not sure about creating a new one.
tcs_ulrich
Posts: 44
Joined: Mon Aug 28, 2017 10:11 am

Re: Scripting Path workbench

Post by tcs_ulrich »

Ive found an solution i can Create an TC with

Code: Select all

drill1mm = Path.Tool("1mm Endmill",tooltype="EndMill",diameter=1)
tc1mm = PathToolController.Create('drill1mm', tool=drill1mm)
And Assign with

Code: Select all

FontCut.ToolController = tc1mm
alanchackomathew
Posts: 20
Joined: Sat Oct 03, 2020 12:28 pm

Re: Scripting Path workbench

Post by alanchackomathew »

etrombly wrote: Fri Mar 20, 2020 4:13 pm This is how I create a PathCustom and assign it to a job and toolcontroller. You should be able to modify it to do what you need.

Code: Select all

obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "Custom")
    PathScripts.PathCustom.ObjectCustom(obj)
    obj.ViewObject.Proxy = 0
    obj.Gcode = gcode
    PathScripts.PathUtils.addToJob(obj)
    obj.ToolController = PathScripts.PathUtils.findToolController(obj)
edit: This just assigns the first active tool. Not sure about creating a new one.
How you created a job using python.
alanchackomathew
Posts: 20
Joined: Sat Oct 03, 2020 12:28 pm

Re: Scripting Path workbench

Post by alanchackomathew »

etrombly wrote: Fri Mar 20, 2020 4:13 pm This is how I create a PathCustom and assign it to a job and toolcontroller. You should be able to modify it to do what you need.

Code: Select all

obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "Custom")
    PathScripts.PathCustom.ObjectCustom(obj)
    obj.ViewObject.Proxy = 0
    obj.Gcode = gcode
    PathScripts.PathUtils.addToJob(obj)
    obj.ToolController = PathScripts.PathUtils.findToolController(obj)
edit: This just assigns the first active tool. Not sure about creating a new one.
Hi, how you created the job using python command. Could you help me please?. Its dor my project. I have to automate the path process.
etrombly
Posts: 144
Joined: Thu Dec 05, 2019 6:50 pm

Re: Scripting Path workbench

Post by etrombly »

I haven't created a job with python before. It would be something along the lines of:

Code: Select all

from PathScripts import PathJob
job = PathJob.create("job_name", "model_object")
That was giving me an error, but is pretty close to what you would need to do. Maybe someone else that has tried it before can help more.
wildzero
Posts: 2
Joined: Sat Apr 15, 2023 12:09 am

Re: Scripting Path workbench

Post by wildzero »

Any update on this issue? Have exactly the same problem creating a path job via python
chrisb
Veteran
Posts: 54166
Joined: Tue Mar 17, 2015 9:14 am

Re: Scripting Path workbench

Post by chrisb »

wildzero wrote: Sat Apr 15, 2023 12:12 am Any update on this issue? Have exactly the same problem creating a path job via python
Please describe in detail what you have tried, and where it fails and what is the result.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
wildzero
Posts: 2
Joined: Sat Apr 15, 2023 12:09 am

Re: Scripting Path workbench

Post by wildzero »

Please describe in detail what you have tried, and where it fails and what is the result.
Thank you for the query. I have no problems after realizing how a path job is basically created

Code: Select all

import PathScripts.PathJob as PathJob
PathJob.Create(name, base)
Without documentation it was just a bit fiddly to find the commands. I'm digging through the src/Mod/Path/PathTests folder to gather the appropriate information.

Some more end user documentation on the subject would be appreciated. But so far I'm getting by.
Post Reply