-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Super Slicer thumbnail generating script
- Loading branch information
1 parent
6244109
commit 6bb304a
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |