Python Post-processing Scripts - Manage OUTPUT file
Hi all,
according to the docs ( https://help.prusa3d.com/article/post-processing-scripts_283913 ) the slicer apply the script to a locally stored temporary file, and you are able to obtain this file, inside your python script, using the code:
sourceFile=sys.argv[1]
You can also obtain the final gCode output path by using:
ps_output_name = str(getenv('SLIC3R_PP_OUTPUT_NAME'))
Then. now you are able to process the temporary source gCode starting with this kind of code:
with open(sourceFile, "r") as input_gcode:
All good so far, but now how to save the results into the final gCode output path, without creating a new gCode file?
Because while processing the temporary file you can transcribe, line by line, the temporary gCode into a new file (maybe by some if condition), but now you would have a second file instead of just saving the processing result into the Slicer final output file!
What I'm ignoring?
Thank you so much!
RE: Python Post-processing Scripts - Manage OUTPUT file
you write your output code back to the input file.
with open(sourceFile,"w") as out_file: