Modifying a Post Processor?

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!
Post Reply
User avatar
JoshM
Posts: 456
Joined: Thu Oct 05, 2017 5:34 pm
Location: New Hampshire

Modifying a Post Processor?

Post by JoshM »

I finally figured out what Brad was driving at about modifying my Post-Processor to meet my machine requirements for embedding Manual Tool Changes in my job. What I'm unclear about is how to have Path look to a Post-Processor in an external folder. Since I end up with a new update for Freecad every day or two, I was hoping not to have to copy my modified post-processor into my newest Freecad folder every time. But, when I look at the FC->Edit->Preferences->Path->Job-Preferences->Post-Processor, it's unclear to me if this is possible--any suggestions?

Regarding the modifications we made, they were as follows:

Best Regards,
Josh



My first mistake was thinking the Full-Stop was used at all. I deleted those--and the accompanying Custom-GCode to turn park and turn off my spindle from my project.

Then I got help from my boss to modify a copy of the LinuxCNC post-processor to include variables for CurrentTool, and LastToolUsed. I hadn't dealt with Python before, and though he's a software programmer, it'd been a while, and he had forgotten how significant the difference between TABS and SPACES was, but quickly remembered.... We modified the LinuxCNC post-processor as follows:

1. We introduced variables: currenttool and LASTTOOLUSED. LASTTOOLUSED is initialized to "firsttime".
2. In the script, following: # Check for Tool Change, the code changed to:

# Check for Tool Change:
if command == 'M6':
if currenttool != LASTTOOLUSED:
if LASTTOOLUSED != "firsttime":
for line in TOOL_CHANGE.splitlines(True):
out += linenumber() + line
LASTTOOLUSED = currenttool
#out += LASTTOOLUSED
if command == "message":
if OUTPUT_COMMENTS is False:
out = []
else:
outstring.pop(0) # remove the command
etc.......

3. In the "TOOL_CHANGE" area Brad pointed me to in the Post-Processor, I added code to move to a Safe-Z location using the machine-Coordinates, Stop the Spindle, and issue a Program-Pause.

# Tool Change commands will be inserted before a tool change
TOOL_CHANGE = '''

G53 G0 Z-3.0 (Move to 3mm below the Z-Home Switch, using Machine-Coordinates)
M05 (Stop The Spindle)
M00 (Program Stop issued to Mach3)

'''
Attachments
ModifiedLinuxCNC_Post.py
(12.09 KiB) Downloaded 152 times
User avatar
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Modifying a Post Processor?

Post by sliptonic »

JoshM wrote: Mon Oct 16, 2017 1:39 pm I finally figured out what Brad was driving at about modifying my Post-Processor to meet my machine requirements for embedding Manual Tool Changes in my job. What I'm unclear about is how to have Path look to a Post-Processor in an external folder. Since I end up with a new update for Freecad every day or two, I was hoping not to have to copy my modified post-processor into my newest Freecad folder every time. But, when I look at the FC->Edit->Preferences->Path->Job-Preferences->Post-Processor, it's unclear to me if this is possible--any suggestions?
Path will automatically look in your macro directory for post and pre processors. Just make sure you follow the naming convention XXXX_post.py
Once it's there, it should appear in the list in the Path Preferences like any other post.
User avatar
JoshM
Posts: 456
Joined: Thu Oct 05, 2017 5:34 pm
Location: New Hampshire

Re: Modifying a Post Processor?

Post by JoshM »

Thanks Brad--that's working perfectly now.

Thanks for the Drill/Helix fix on today's update--was thrilled to be able to modify a job and not have to remap those items!

Best Regards,
Josh
Post Reply