MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.1k stars 19.19k forks source link

Defining and Using Variables in GCode #23065

Open jweiss2 opened 2 years ago

jweiss2 commented 2 years ago

Is your feature request related to a problem? Please describe.

I am relatively new with Marlin and GCode, but I tried incorporating variables in my GCode (as described here: https://gcodetutor.com/cnc-macro-programming/cnc-variables.html) without success. I searched in the forums and found a post asking for this feature about 10 years ago with no update. I am just trying to optimize a value for a very repetitive movement, and being able to define a variable would save a lot of time when troubleshooting.

Thanks!

Are you looking for hardware support?

No response

Describe the feature you want

Support for defining and using variables in GCode as described here: https://gcodetutor.com/cnc-macro-programming/cnc-variables.html

Additional context

No response

DerAndere1 commented 2 years ago

The following is not a solution for existing gcode that includes variables, but it can serve as a workaround (or even a more powerful alternative) for those who are willing to learn Python basics to write new scripts: Use printcore (comes with printrun) as described at https://github.com/kliment/Printrun#using-printcore or use the python package mecode to generate/send gcode. pronterface and pronsole have their own macrosystem. It is obviously just a workaround because the format is not standarized internationally.

stevekenney318 commented 1 year ago

I would also love to see this feature added for use in Marlin gcode... I'm really quite surprised it's not there.

Thanks, Steve

DerAndere1 commented 3 weeks ago

Also interesting: a library that can be used by G-code senders to post-process LinuxCNC G-code and expand variables and o-codes: https://github.com/NRSoft/GSharp

And there is an old pull request which is work in progress: https://github.com/MarlinFirmware/Marlin/pull/24654