Using variables as GCode argument keys
-
Hi,
I'm trying to write some gcode expressions like so:
G1 {global.extruder_axis}2
G1 {global.extruder_axis ^ "2"}
G1 {"E2", "F600"}
M92 {global.extruder_axis ^ global.extruder_steps}
But all of these result in no action occurring, it seems that the gcode parser ignores the argument keys that evaluate as a result of the expression. (Basically, it's like G1 without arguments, or M92 without arguments).
I have a workaround, but I really don't like it, is there something that can be done to support the above use-case? @dc42 thoughts?
echo >"tmp.g" "G1 " ^ global.extruder_axis ^ 2 M98 P"tmp.g" M400 M30 "sys/tmp.g"
-
This post is deleted! -
Another work-around would be to pass a parameter with the desired axis and use that value in a series of IF statements.
Frederick
-
@fcwilt said in Using variables as GCode argument keys:
Another work-around would be to pass a parameter with the desired axis and use that value in a series of IF statements.
Frederick
This approach wouldn't work as there would be any axis, not XYZE. It could be any if UVWABCD and I don't want to repeat the same line of code for each with only the single letter changed.
-
@pfn said in Using variables as GCode argument keys:
This approach wouldn't work as there would be any axis, not XYZE. It could be any if UVWABCD and I don't want to repeat the same line of code for each with only the single letter changed.
Well it would work but if you don't care for it that is entirely up to you.
Frederick
-
@fcwilt it's not a scalable solution
-
@pfn said in Using variables as GCode argument keys:
G1 {global.extruder_axis}2
this is invalid, should be
G1 {global.extruder_axis}^2
@pfn said in Using variables as GCode argument keys:
G1 {"E2", "F600"}
This should be
G1 {"E2"^" "^"F600"}
However I have confirmed the core issue in tests, you cannot pass string arguments within gcode meta commands in the way you are trying to do. This impacts situations like this:
M92 {global.extruder_axis}^100
as well as the combinations you have used above.however
M92 E{global.extruder_steps}
Should work.Will flag this to @dc42.
-
@pfn we have updated the documentation to make this clear. :
https://duet3d.dozuki.com/Wiki/GCode_Meta_Commands?#Section_Use_of_expressions_within_GCode_commands
And I will move this discussion to the firmware wishlist category.
-
@T3P3Tony leaving this here if it comes up in searches. There is a feature request for this here:
https://github.com/Duet3D/RepRapFirmware/issues/708
Related to this request:
https://forum.duet3d.com/topic/35660/passing-axis-letters-as-macro-parameters-to-m98