You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
MarlinFirmware/E3S1PROFORKBYTT_superslicer...

42 lines
1.0 KiB
Python

#!/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()