There are some things that PrusaSlicer simply doesn’t do. However, using post-processing scripts you can automatically modify the generated G-code to do (almost) anything you want.
You can specify the path to the script in Print settings - Output options - Post-processing scripts.
Post-processing scripts can be written in any programming language (Perl, Python, Ruby, Bash etc.). They just need to be recognized by your system as an executable and accept the path to the G-code file as the only argument.
If you want to run several scripts, put each script invocation into its own line.
Each script will be passed the absolute path of a temporary G-code file that PrusaSlicer generates. This file is stored in a temporary folder on your drive (typically your fast system drive). The script is then executed to modify the G-code in place and the resulting G-code file is written to your selected target folder or sent to a print host, such as PrusaConnect or Octoprint.
You can use parameters with your script as such:
/path/to/executable becomes /path/to/executable with the arg outputfilename.gcode
/path/to/executable -arg -arg2 becomes /path/to/executable with args -arg, -arg2, and outputfilename.gcode
If path to executable or arguments contain spaces, these arguments need to be escaped using the escaping style common to the platform (shell escaping style on Linux and OSX, Windows command line escaping).
Path to the final exported file (or its name for Octoprint)
env_slicer_pp_output_name = str(getenv('SLIC3R_PP_OUTPUT_NAME'))
Python script that modifies the output path
with open(sourcefile + '.output_name', mode='w', encoding='UTF-8') as fopen: fopen.write(counter + '_' + env_slicer_pp_output_name)
Before version 2.4, PrusaSlicer used to execute the script on the final G-code exported to your desired target medium. Which was very often a removable drive, such as an SD card. SD cards are slow and wear out, so this was not ideal. There were also problems when sending the G-code to Octoprint. The new approach with the temporary file on your system drive prevents these problems and extends the functionality of post-processing scripts. However, it might break some of your existing scripts.
If you have a question about something that isn't covered here, check out our additional resources.
And if that doesn't do the trick, you can send an inquiry to email@example.com or through the button below.