Skip to content

Commit

Permalink
Super Slicer thumbnail generating script
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasToka committed Sep 12, 2023
1 parent 6244109 commit 6bb304a
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions E3S1PROFORKBYTT_superslicer_thumbnail.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 6bb304a

Please sign in to comment.