Feature Request: Ability to rename_existing G1

I am working on using Klipper to run a laser engraver and would like to be able to modify G1 gcode on a firmware level (using either a Klippy/extras .py module, or via a .cfg macro). So far this does not seem possible, though I could certainly be wrong. Any insight into this would be appreciated.

In the simplest of forms, I would like to be able to get the below macro working:

[gcode_macro G1]
rename_existing: G1.1 # Rename the existing G1 command to G1.1
gcode:
{% set cmd = params|join(’ ') %}
G1.1 {cmd} ; Call the renamed G1 command with ‘E’ removed

Console:
Input: “G1 X50 Y35 E2 F1600”
Desired Output: “G1.1 X50 Y35 E2 F1600” or “G1.1 G1 X50 Y35 E2 F1600”
Actual Output: !! Unable to parse move ‘G1.1 G X Y E F’

Input: G1.1 X50 Y35 E2 F1600 or G1.1 G1 X50 Y35 E2 F1600
Output: Works as expected. Printer moves to X50 Y35. No errors or issues.

It seems close to working, but does not produce the desired results, it seems to strip all numbers from G1 commands resulting in “G1.1 G X Y E F” style commands, which of course produces an error as it is looking for coordinates

Hi @Braff ,

I think what you’re looking for is rawparams.

[gcode_macro G1]
rename_existing: G1.1 # Rename the existing G1 command to G1.1
gcode:
{% set cmd = params|join(’ ') %}
G1.1 {rawparams} ; Call the renamed G1 command with ‘E’ removed

Keep in mind you will have to do some processing on the rawparams string to remove the E parameter.

2 Likes

Holy $*#& thank you so much! Man ChatGpt is cool, but also garbage at the same time. Simple question posted to a human set me in the right direction after hours of going in circles with GPT. Thank you so much

That’s the reason we don’t rely on AI here. If we need a good laugh, yes. But not for serious issues.

1 Like