Delete E3S1PROFORKBYTT_prusa_thumbnail.py
parent
a585bb1ef9
commit
a13088ed3a
@ -1,47 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
#
|
|
||||||
# Prusa 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]
|
|
||||||
|
|
||||||
try:
|
|
||||||
# Read the ENTIRE g-code file into memory
|
|
||||||
with open(sourceFile, "r", encoding="utf8") as f:
|
|
||||||
lines = f.readlines()
|
|
||||||
except Exception as e:
|
|
||||||
print("Error opening source file: {0}".format(str(e)))
|
|
||||||
input()
|
|
||||||
finally:
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
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 PrusaSlicer'):
|
|
||||||
remove_next_line = True
|
|
||||||
elif remove_next_line and line.strip() == '':
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
new_lines.append(line)
|
|
||||||
|
|
||||||
try:
|
|
||||||
with open(sourceFile, "w+", encoding="utf8") as of:
|
|
||||||
of.write(''.join(new_lines))
|
|
||||||
except Exception as e:
|
|
||||||
print("Error writing output file: {0}".format(str(e)))
|
|
||||||
input()
|
|
||||||
finally:
|
|
||||||
of.close()
|
|
Loading…
Reference in New Issue