From 0fbb5ee9e27ba904aa9d4aa4583d5ea289b7e322 Mon Sep 17 00:00:00 2001 From: Phuck Date: Sun, 6 Aug 2023 23:44:24 -0400 Subject: [PATCH] automatically preprend config.g to the job --- README.md | 10 ++++++---- rewritegcode.py | 7 ++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e1b1114..28efc51 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,12 @@ The hacked together pipeline is as follows given an svg `$SVG`. You may use the 1. Ensure that your SVG has a size set that fits in Ooza 1. One way to ensure is by setting width & height on the root `` element -2. Covert the SVG to gcode via `cargo run --release -- $SVG -o $OUTFILE` -3. Rewrite the gcode to center where the print happens via `python rewritegcode.py $OUTFILE $UPDATEFILE` -4. Generate the final file by concatenating the header to the updated file via `cat ooza/config.g $UPDATEFILE > $FINALEFILE` -5. Upload `$FINALFILE` to Jobs in Duet and run it +1. Convert the SVG to gcode via `cargo run --release -- $SVG -o $OUTFILE` +1. Rewrite the gcode to be compatible with Ooza via `python rewritegcode.py $OUTFILE $FINALFILE`. This will do a few things: + 1. Exit with an error message if the print would go outside the bounds of Ooza + 1. Rewrite the coordinates to center where the print happens + 1. Prepend the header in `ooza/config.g` to the rewritten gcode +1. Upload `$FINALFILE` to Jobs in Duet and run it # svg2gcode diff --git a/rewritegcode.py b/rewritegcode.py index 08a40e3..1ed07e1 100644 --- a/rewritegcode.py +++ b/rewritegcode.py @@ -19,6 +19,8 @@ MAXX = 650 MINY = 200 MAXY = 1000 +OOZA_HEADER_PATH = "ooza/config.g" + @dataclass class GCodeInfo: @@ -136,7 +138,10 @@ def rewrite_gcode(infile, outfile): print(format_info_error(info)) return 1 - outfile.write(lines) + with open(OOZA_HEADER_PATH) as fp: + header = fp.read() + + outfile.write(header + lines) return 0 if __name__ == "__main__":