Developing a Preprocessor That Requires The Whole File


#1

Hi there. I've been trying to write a plugin that converts a sliced GCode file to Polar Coordinates for my Polar3D printer. I figured the file preprocessing hook would be good for this, but the whole thing with that is that you process it as a stream, line by line. The polar3dconvert program takes the whole gcode file and rewrites it in place. I've tried a bunch of things to make this happen, but it seems that the whole "streaming line by line" thing seems to break it.

Here's everything I remember trying.

  • Hardcoding the path and running the program on it
  • Copying the hardcoded path to /tmp, running the file, and copying it back
  • Capturing the input stream in a buffered input stream, writing it to a file in /tmp, running the program, and returning it all on the first line of the process_line output.

I don't know if this is even possible with this kind of hook. Please let me know if this is the best way to do this.


#2

I don't have a delta but if it were me, I think I'd move the entire solution "upstream" if you will. I'd either make something that is a CLI which I'd run before uploading the resulting gcode file to OctoPrint or I'd write something as a Cura post-processing script in my case.

By the time that the file is uploaded to OctoPrint it just seems like that is almost too late.