From 6bb304ae95eaf6bb1edab404fc93b2c700771e88 Mon Sep 17 00:00:00 2001 From: ThomasToka <117008525+ThomasToka@users.noreply.github.com> Date: Tue, 12 Sep 2023 10:09:50 +0200 Subject: [PATCH] Super Slicer thumbnail generating script --- E3S1PROFORKBYTT_superslicer_thumbnail.py | 42 ++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 E3S1PROFORKBYTT_superslicer_thumbnail.py diff --git a/E3S1PROFORKBYTT_superslicer_thumbnail.py b/E3S1PROFORKBYTT_superslicer_thumbnail.py new file mode 100644 index 0000000..c8ace63 --- /dev/null +++ b/E3S1PROFORKBYTT_superslicer_thumbnail.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python3 +# +# Superslicer Slicer remove headers before jpg. +# +# This script has been developed for E3S1PROFORKBYTT by Thomas Toka. +# +# Intruduced with v008 into E3S1PROFORKBYTT. +# ------------------------------------------------------------------------------ + +import sys +import os + +# Get the g-code source file name +sourceFile = sys.argv[1] + +# Read the ENTIRE g-code file into memory +with open(sourceFile, "r") as f: + lines = f.readlines() + +new_lines = [] +remove_next_line = False + +for line in lines: + if remove_next_line and line.strip() == ';': + remove_next_line = False + continue + if line.startswith('; generated by SuperSlicer'): + remove_next_line = True + elif remove_next_line and line.strip() == '': + continue + else: + new_lines.append(line) + +try: + with open(sourceFile, "w+") as of: + of.write(''.join(new_lines)) +except: + print('Error writing output file') + input() +finally: + of.close() + f.close() \ No newline at end of file