Wiki Path Postprocessor Customization

Here's the place for discussion related to CAM/CNC and the development of the Path module.
chrisb
Posts: 22315
Joined: Tue Mar 17, 2015 9:14 am

Wiki Path Postprocessor Customization

Postby chrisb » Wed Feb 12, 2020 10:42 am

I was tired to repeat another time what I would like to see in order to get started with a new post processor. So I just added contents to the Path Postprocessor Customization page. I asked already in the wiki forum for formal and layout improvements - I was glad to get the images included and get the poor layout - but here I would ask for input about the contents.
mlampert
Posts: 1460
Joined: Fri Sep 16, 2016 9:28 pm

Re: Wiki Path Postprocessor Customization

Postby mlampert » Wed Feb 12, 2020 7:07 pm

Great page - are you looking for a review or for content?
If it's the latter, do you have an outline of what should go there?
chrisb
Posts: 22315
Joined: Tue Mar 17, 2015 9:14 am

Re: Wiki Path Postprocessor Customization

Postby chrisb » Wed Feb 12, 2020 8:15 pm

I had a review in mind, but content is of course highly welcome. I think it was sliptonic who created the page with some hints to the content. I have included and augmented them.

This page is not yet a complete instruction how to write a post processor, but hopefully we will get there step by step.
User avatar
sliptonic
Posts: 1679
Joined: Tue Oct 25, 2011 10:46 pm

Re: Wiki Path Postprocessor Customization

Postby sliptonic » Thu Feb 13, 2020 2:40 pm

Great start. I added a few more reasons for a custom post to the list.

One thing that I see all the time on the forum is confusion about the first move in the rendered backplot. Newbies always get confused that there's a rapid move from 0,0,0. A truly confused newbie might think, "I need a custom post that doesn't do that" and end up here. Perhaps if we documented the answer somewhere, we could link to it from here.
chrisb
Posts: 22315
Joined: Tue Mar 17, 2015 9:14 am

Re: Wiki Path Postprocessor Customization

Postby chrisb » Fri Feb 14, 2020 7:14 am

sliptonic wrote:
Thu Feb 13, 2020 2:40 pm
One thing that I see all the time on the forum is confusion about the first move in the rendered backplot. Newbies always get confused that there's a rapid move from 0,0,0. A truly confused newbie might think, "I need a custom post that doesn't do that" and end up here. Perhaps if we documented the answer somewhere, we could link to it from here.
I know the reason why this first move is there, somewhere it has to start, and the move to that position is indeed created. As far as I can see there is no possibility to get it really right, but two to get it wrong:

1) The first move is shown as a rapid move, starting from some position, e.g. (0,0,0). This can be rather surprising, especially when (0,0,0) lies somewhere inside or below the model.
---
Right: The first move is a rapid move
Wrong: The start position of that move

2) The display of the first move is suppressed. The first move shown then would be a move which is indeed carried out. This is only possible if the mill is moved to the starting position - which implies the move to that position.
---
Right: No wrong starting position is shown.
Wrong: No visual feedback that the first move exists, no feedback that it is a rapid move.

There is usually not much advantage of one over the other, but there is one rather special use case where the first solution would have a disadvantage: If by a strange coincidence the path ends with an unwanted rapid move to (0,0,0) it could remain undetected, due to the overlay with the first rapid move from (0,0,0).
RatonLaveur
Posts: 463
Joined: Wed Mar 27, 2019 10:45 am

Re: Wiki Path Postprocessor Customization

Postby RatonLaveur » Fri Feb 14, 2020 7:25 am

Gents, it is true that this move is usually set in the postprocessor. It follows the same logical block as specifying the work coordinate system offset.
Generally you'll open your code with prep functions
G17G40G90G54
G00Z{safe height}
G00X0Y0
G00Z{clearance height}

-----Operations-----

This is just basic off the cuff example. But all that generally appears in the post pro. Usually an option "move to start?"

But there are different philosophies and need. I can only describe what I see on a day to day basis.
Hj36DyP0
Posts: 2
Joined: Mon Feb 17, 2020 4:38 am

Re: Wiki Path Postprocessor Customization

Postby Hj36DyP0 » Mon Feb 17, 2020 4:53 am

Hello folks:

I've been playing around with Freecad's Path workbench on 0.18, under linux. I'm trying to come up with some specific PREAMBLE and POSTAMBLE, see them taken from /usr/lib64/freecad/Mod/Path/PathScripts/post/linuxcnc_post.py as

# Preamble text will appear at the beginning of the GCODE output file.
PREAMBLE = '''G17 G54 G40 G49 G80 G90
'''

# Postamble text will appear following the last operation.
POSTAMBLE = '''M05
G17 G54 G90 G80 G40
M2
''
I modified the file thinking this will auto generate the output file upon postprocessing, but so far I come up with the same file regardless of my modifications.

I also created a copy of linuxcnc_post.py under a different MACHINE_NAME = "MyTestPre". That also doesn't show up under Job Post Processor properties. I did test adding --precision 2 --no-header --no-comments to Post Processor Args. That is working all right.

So what I'm asking is how to create and where to put my own post processor file for Freecad 0.18 Path workbench to find

Sorry for the english, not my first language. Thanks in advance you're doing an awesome job!
jmaustpc
Posts: 9621
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Wiki Path Postprocessor Customization

Postby jmaustpc » Mon Feb 17, 2020 6:06 am

Hj36DyP0 wrote:
Mon Feb 17, 2020 4:53 am
I've been playing around with Freecad's Path workbench on 0.18, under linux.
Hi and welcome to FreeCAD :D
I don't know enough to answer your question but if you want to have a play with Path WB you really need to be using FreeCAD dev branch currently 0.19 as development of Path WB has been considerable after 0.18 was released.

You have only said on Linux, if you mean Ubuntu then there is a daily PPA so you can have automatic updates, some of the other distros also have updates from repos and there is the generic packages, or of course compiling.

Jim
chrisb
Posts: 22315
Joined: Tue Mar 17, 2015 9:14 am

Re: Wiki Path Postprocessor Customization

Postby chrisb » Mon Feb 17, 2020 6:24 am

If you want to use 3D surface - for the latest development see https://forum.freecadweb.org/viewtopic.php?f=15&t=41997 - you need the opencamlib library. You can compile it yourself - and use the PPA - or use the AppImage, which contains the precompiled library.

The postprocessor should work in 0.18 too. You may have to restart FreeCAD.
User avatar
sliptonic
Posts: 1679
Joined: Tue Oct 25, 2011 10:46 pm

Re: Wiki Path Postprocessor Customization

Postby sliptonic » Mon Feb 17, 2020 4:36 pm

Hj36DyP0 wrote:
Mon Feb 17, 2020 4:53 am

I modified the file thinking this will auto generate the output file upon postprocessing, but so far I come up with the same file regardless of my modifications.
The post-processor is a python module so it needs to be reloaded before the changes become effective. You can either restart FreeCAD, or just switch your chosen post and then switch it back.
I also created a copy of linuxcnc_post.py under a different MACHINE_NAME = "MyTestPre". That also doesn't show up under Job Post Processor properties. I did test adding --precision 2 --no-header --no-comments to Post Processor Args. That is working all right.

So what I'm asking is how to create and where to put my own post processor file for Freecad 0.18 Path workbench to find
I don't think the MACHINE_NAME variable in the post processor is actually used anywhere. The name that appears in the list is parsed from the name of the postprocessor module. So if you name your new post MyTestPre_post.py and place it in your macro directory or the directory specified in Preferences->Path->Job Preferences->Path, it should appear in the list.