I'm building a plugin for supporting the laser and CNC functions on a Snapmaker 3 in 1 printer's CNC / laser. (https://ron-linkertech.github.io/octoprint-snapmaker-control/)
I have run into many issues, so I'm starting a topic here to discuss them and get some ideas.
I have never used knockoutjs before, and I'd call my python skills "passable", but I have done a multitude of different languages over the years and it was not hard to get a functional plugin for the simple case of detecting and turning on and off the laser / cnc. Beyond that is where the issues started...
Here are some things I've learned about CNC. I'm a noob here, so I may have any of this wrong for the general case; I've only got what Snapmaker provided me with and a little googling. The gcode files that are created in the CNC / Laser space have a file extension of "nc" rather than "g", "gco", or "gcode". The files themselves do not have extruder parameters in the G(0,1) codes, but do have separate M3, M4, M5 commands to turn the tool on and off.
Initially I only wanted the controls to show up on the control tab when the specific printer is detected and the laser or CNC tool is on. It looks like the control.yaml approach would not support the conditional stuff I needed, so I just made them add themselves to the DOM based on my plugin finding the printer in the gcode stream. Knockout did not like me putting things in the control tab, so they are anchored below the tab container.
I wanted to find the boundary of the loaded file in order to support a "run boundary" tool, which is used to move the head in the x and y direction around your laser / cnc work to make sure it will fit where you want it.
The file manager does not support these files when uploading, so I intended to do a PR to allow this, but when I changed this locally and loaded a file, the existing analysis does not find the bounds of the file, as these files don't use an "extruder", and this is what is used to find the minxy maxxy. It also looks like the gcode tool will have issues, but I have not looked at this code yet to see how easy it would be to change to show "tool down" instead of "extrude" paths in the gcode.
I am starting to get that sinking feeling that this will be a lot harder than I thought, but I'd welcome some comments here about approaches I may be missing or other thoughts.
-Ron