Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip pre- first layer code, handle setting with '='. #83

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions prusa_slicer_post_processing_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ def main(gCodeFileStream,path2GCode,skipInput)->None:
input("Can not run script, gcode unmodified. Press enter to close.")
raise ValueError("Incompatible Settings used!")
layerobjs=[]
startuplines = []
gcodeWasModified=False
if gCodeFileStream:
layers=splitGCodeIntoLayers(gCodeLines)
startuplines = layers.pop(0)
gCodeFileStream.close()
print("layers:",len(layers))
lastfansetting=0 # initialize variable
Expand Down Expand Up @@ -375,6 +377,7 @@ def main(gCodeFileStream,path2GCode,skipInput)->None:
print("overwriting file")
else:
print("write to",path2GCode)
f.writelines(startuplines)
for layer in layerobjs:
f.writelines(layer.lines)
f.close()
Expand Down Expand Up @@ -1061,15 +1064,12 @@ def readSettingsFromGCode2dict(gcodeLines:list,fallbackValuesDict:dict)->dict:
isSetting=True
continue
if isSetting :
setting=line.strip(";").strip("\n").split("= ")
setting=line.strip(";").strip("\n").split("= ", 1)
if len(setting)==2:
try:
gCodeSettingDict[setting[0].strip(" ")]=literal_eval(setting[1]) # automaticly convert into int,float,...
except:
gCodeSettingDict[setting[0].strip(" ")]=setting[1] # leave the complex settings as strings. They shall be handled individually if necessary
elif len(setting)>2:
gCodeSettingDict[setting[0].strip(" ")]=setting[1:]
warnings.warn(f"PrusaSlicer Setting {setting[0]} not in the expected key/value format, but added into the settings-dictionarry")
else:
print("Could not read setting from PrusaSlicer:",setting)
if "%" in str(gCodeSettingDict.get("perimeter_extrusion_width")) : #overwrite Percentage width as suggested by 5axes via github
Expand Down