I am using the custom button plugin with a CNC 3018 and the CNC plugin and getting almost exactly the results I want. I have a button to probe the "0" corner of the workpiece using the cutter. When the cutter touches the workpiece, the coordinate is set to - 1/2 the cutter diameter. Then "0" will be the middle of the cutter.
I have an input field and my G code for that step is "G92 X%(value)s". It works - so long as you enter a negative value that is 1/2 the tool diameter. I have a calculator and I am smart enough to tie my own shoes, so it's not a debilitating step to enter the correct number, but it sure would be nice to just enter a positive value for the diameter and have the machine do "-1/2*%(value)s". Of course, when I tried that, it errored out. Is there a way to get the machine to do the math in a custom button?
Correct, has to be done as a script. The scripts are rendered with Jinja2, which allows for template syntax to be used to do the calculations. The standard gcode scripts are just sent straight to the printer with not much processing done.
You might also be able to do it with a JavaScript snippet to be executed when you press the button. At that point you're halfway to making your own plugin
That's a good point Charlie, a javascript snippet would be a possibility using data in the function call if I'm reading the docs properly. So something like this?