Who knows Python (FreeCAD PostProcessor)
I realised if I output in millimeters, the A axis output is fine, it looks like degrees. My machine is setup in inches so when I output the inches gcode the A axis output is basically divided by 25.4. So I need to get this postprocessor script to ignore the A axis when it's converting to inches. I'm not a Python guy so I'm looking for help here.
Attachments:
Please Log in or Create an account to join the conversation.
I'm not a python expert either but I don't see anything that looks like unit conversion in that script.So I need to get this postprocessor script to ignore the A axis when it's converting to inches.
Please Log in or Create an account to join the conversation.
AFAICT your right, looks like it's passing the inch argument back to Freecad and it's doing the conversion. I figured maybe something could be passed to tell it not to convert the rotary axis, or at the very least multiply the rotary outputs by 25.4 to convert it back to degrees.
So I need to get this postprocessor script to ignore the A axis when it's converting to inches.
I'm not a python expert either but I don't see anything that looks like unit conversion in that script.
Please Log in or Create an account to join the conversation.
- tommylight
- Away
- Moderator
- Posts: 19300
- Thank you received: 6462
Please Log in or Create an account to join the conversation.
pos = Units.Quantity(
c.Parameters[param], FreeCAD.Units.Length
)
outstring.append(
param
+ format(
float(pos.getValueAs(UNIT_FORMAT)), precision_string
)
)
When processing the 'A' word then 'param' would be equal to 'A' and 'pos' would be the angle value (wrongly getting divided by 25.4) so may be you could add an if statement that would multiply the pos value by 25.4 IF param == 'A'.
Please Log in or Create an account to join the conversation.
pos = Units.Quantity(
c.Parameters[param], FreeCAD.Units.Length
)
if param == 'A':
pos = pos * 25.4
outstring.append(
param
+ format(
float(pos.getValueAs(UNIT_FORMAT)), precision_string
)
)
Please Log in or Create an account to join the conversation.
Is it possible to have that if statement consider the --inches parser argument?
Didn't mention it in the first post but the A-axis Gcode FreeCAD was outputting also ran -180 to 180. I don't know if that's normal or if LinuxCNC can be configured to use that setup. Mine is setup as "wrapped rotary" and it will travel infinite degrees in either direction. The code it was originally outputting looked like it would travel halfway around the part and then travel back in the other direction on my setup. One of the guys on the FreeCAD forum fixed that in the PP script so it now outputs 0-360 then returns to 0 for the next pass, it looks more convincing now.
So this is the current script with Aciera's changes as well as what bmsaus4ax on the FreeCAD forum did.
Attachments:
Please Log in or Create an account to join the conversation.
else:
pos = Units.Quantity(
c.Parameters[param], FreeCAD.Units.Length
)
if param == 'A' and UNITS == 'G20':
pos = pos * 25.4
outstring.append(
param
+ format(
float(pos.getValueAs(UNIT_FORMAT)), precision_string
)
)
Please Log in or Create an account to join the conversation.
That seems to do the trick for mm and inches. I think I can run this output after I manually fix the feedrate.
Gonna post this on the freecad forum as well since it might be helpful.
Attachments:
Please Log in or Create an account to join the conversation.