Prusa
  • SHOP
    • Latest products
    BY CATEGORY
    • 3D printersnew
    • 3D printer upgradesnew
    • Materials
    • Accessories
    • Spare parts
    • Courses
    • Merch
    • Get a price quote
    QUICK LINKS
    • Shipping & delivery
    • Returns & refunds
    • Payment & financing
    • Warranty
    • VAT & Customs fees
    • FAQ

    0 item in your cartitems in your cart

    Your cart is empty

    Go to cartShop 3D printers

    My profile

    Log in to see orders, saved items

    My profile

    Signed in as

    • Orders
    • Logout
  • 3D PRINTING
    • Explore 3D printing
    FOR BEGINNERS
    • 3D printing 101
    • How FDM printing works
    • Buying your first printer
    • 3D model catalog
    BY APPLICATION
    • Rapid prototyping
    • Manufacturing
    • Engineering
    • Research
    • Arts & design
    GO DEEPER
    • Materials guide
    • Courses
    • Webinars
    • Case studies
    • Custom 3D printing
  • 3D PRINTERS
    • All 3D printers
    FOR
    • Home or garageHobbyists, tinkerers and home printing
    • BusinessIn-house production for small teams
    • EnterpriseFleets, security and scale
    • Which Prusa is right for me
    SHOP & BROWSE
    • CORE One+new
    • CORE One+ INDXnew
    • CORE One L+new
    • CORE One L+ INDXnew
    • XL+new
    • MK4S
    • Prusa Pro HT90
    • Prusa Pro AFS
    • Prusa Pro SLX
    MORE FROM PRINTERS
    • Parts & upgradesnew
    • Spare parts
    • Critical infrastructure
    • Case studies
    • Signature Oak
    • Kits
  • MATERIALS
    • All materials
    BY USE
    • Every-day & design
    • Functional engineering
    • Composites
    • Pro speciality
    • SLA resins
    PRUSAMENT
    • PLA
    • PETG
    • ASA
    • PC
    • PA11
    • Flex
    • TPU
    MORE FROM MATERIALS
    • Materials guide
    • We make material in house
    • Sustainability
    • Order on the store
  • SOFTWARE
    • All software
    PREPARE THE PRINT
    • PrusaSlicer 3.0New
    PRINT & MONITOR
    • Prusa Connect
    • EasyPrint
    • iOS & Android app
    • Prusa Farm
    GET STARTED
    • Download & install
    • Knowledge base
    MORE FROM SOFTWARE
    • 3D model catalog
  • SUPPORT
    • Explore support
    FIND ANSWERS
    • Knowledge base
    • Troubleshooting
    • Courses
    • Webinars
    GET HELP
    • Contact us
    • Livechat
    • Shipping & delivery
    • Warranty
    • Returns & refunds
    • Service & spare parts
    • Service & Repair
    COMMUNITY
    • Forum
    • Reddit
    • Printables
  • TRUST CENTER
    • Trust Center overview
    BY TOPIC
    • GDPR
    • Certificates
    • Security
    • Compliance
    COMMITMENTS
    • Sustainability report
    TALK TO US
    • Contact the security team
  • COMPANY
    • About Prusa
    GET TO KNOW US
    • Our story
    • How we make printers
    • Open source
    • Brand & media kit
    NEWS
    • Blog
    • Newsroom
    • Events
    TRUST & PARTNERS
    • Sustainability
    • Resellers & distributors
    • Affiliate program
    • Contact
    • English
    • Čeština
    • Deutsch
    • Español
    • Français
    • Italiano
    • Polski
    • 日本語
  • Signed in as

    • Orders
    • Address
    • In-stock Alerts
    • My Courses
    • Subscription
    • Edit Account
    • Logout

Log in to see orders, saved items

Signed in as
  • Orders
  • Address
  • In-stock Alerts
  • My Courses
  • Subscription
  • Edit Account
  • English
  • Čeština
  • Deutsch
  • Español
  • Français
  • Italiano
  • Polski
  • 日本語
Shop

0 item in your cartitems in your cart

Your cart is empty

Go to cartShop 3D printers

My profile

Log in to see orders, saved items

My profile

Signed in as

  • Orders
  • Logout
SHOP
  • Latest products
BY CATEGORY
  • 3D printersnew
  • 3D printer upgradesnew
  • Materials
  • Accessories
  • Spare parts
  • Courses
  • Merch
  • Get a price quote
QUICK LINKS
  • Shipping & delivery
  • Returns & refunds
  • Payment & financing
  • Warranty
  • VAT & Customs fees
  • FAQ

Featured products

    Popular categories

      Trending searches

        Articles

          Blog

            Products

              Categories

                Suggested searches

                  Searching…
                  No results
                  Something went wrong.
                  ↑↓ Select↵ OpenEsc Close search
                  1. Support
                  2. Advanced features
                  3. Post-processing scripts
                   

                  Contents

                  • Script setup
                  • Script execution
                  • Script Parameters
                  • Examples
                  • Historical changes and breaking backward compatibility

                  Blog

                  • Prusament Pellets: Raw material batches for large-format 3D printing or small-scale polymer research & development
                  • Print colorful and glowing Halloween decorations with our spooky offer
                  • Factorio Has Arrived on Printables

                  Newsletter

                  Signup and get our monthly squeeze on updates, blog, printables and much more.

                  By clicking, you agree to receive our newsletter.

                  This site is protected by reCAPTCHA Enterprise and the Google Privacy Policy and Terms of Service apply.

                  Heavy Duty Keyboard Holder (No Supports)
                  E-shop
                  • 3D Printers
                  • Printer Upgrades
                  • Filaments
                  • Accessories
                  • Prusa Merchandise
                  Prusa

                  © Prusa Research a.s.

                  Printables
                  • 3D Models
                  • Store
                  • Clubs
                  • 3D Design Contests
                  • Brands
                  Community
                  • World Map
                  • Forum
                  • User Groups
                  • Events
                  Help
                  • Prusa Help
                  • Prusa Academy
                  • 3D Printing Calculators
                  Software
                  • PrusaSlicer
                  • Prusa.app
                  • Prusa Connect
                  • Drivers and Software
                  Company
                  • About Us
                  • Blog
                  • Official Prusa Resellers
                  • Contact Us
                  • Certified for ISO 9001, ISO 14001, ISO 45001
                  • General Terms and Conditions
                  • General Terms and Conditions of Use of the PRUSA Websites
                  • Privacy Policy
                  • Information about cookies
                  • Customer Complaints Policy
                  • Status Page
                  • Do Not Sell or Share My Personal Information
                  • Supplemental Statements
                  Prusa
                  • General Terms and Conditions
                  • General Terms and Conditions of Use of the PRUSA Websites
                  • Privacy Policy
                  • Information about cookies
                  • Customer Complaints Policy
                  • Status Page
                  • Do Not Sell or Share My Personal Information
                  • Supplemental Statements

                  © Prusa Research a.s.

                  JOSEF PRUSA®, PRUSA RESEARCH®, PRUSA POLYMERS®, PRUSA ORANGE®, PRUSA 3D ® AND PRUSAMENT® are registered trademarks of Prusa Development a.s. used by Prusa Research a.s. under licence from Prusa Development a.s.

                  Post-processing scripts

                  Relevant for

                  PrusaSlicer
                  1 comment
                  Article is also available in following languages
                  English
                  Čeština
                  Polski
                  Deutsch
                  Français
                  Español
                  Italiano
                  日本語

                  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.

                  Script setup

                  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.

                  Script execution

                  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.

                  Please note that the G-code viewer still visualizes G-code before post-processing.
                  PrusaSlicer automatically converts all environment variables used in post-processing scripts to uppercase. To ensure compatibility, always reference them using fully capitalized names, such as "SLIC3R_FILL_DENSITY".
                   
                  Two additional environment variables are passed to post processing scripts: The environment variable SLIC3R_PP_HOST provides the host specification, where "File" means copying the G-code to a local hard drive or removable media, while the other values ("PrusaLink", "Repetier", "SL1Host", "OctoPrint", "FlashAir", "Duet", "AstroBox" ...) specify the print host type the G-code will be sent to.
                   
                  The environment variable SLIC3R_PP_OUTPUT_NAME contains the name of the G-code file including path (for SLIC3R_PP_HOST == "File") or a name that will be given to the file after it is uploaded to the host (PrusaLink, Octoprint ...)
                   
                  The post-processing script may suggest a new output file name (likely based on SLIC3R_PP_OUTPUT_NAME) by saving it as a single line into a new "output name" temp file, for example to add time stamps or sequence numbers to the final G-codes.The "output name" file name is to be created by suffixing the input G-code file name with ".output_name". PrusaSlicer will read the new name of the file and handle it properly, for example, when sending it to Octoprint.
                   

                  Script Parameters

                  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).

                  Examples

                  Python

                  Adding counter to the file name example

                  Path to the final exported file (or its name for Octoprint)

                  Python script that modifies the output path

                   

                  Historical changes and breaking backward compatibility

                  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.

                   

                  This documentation page includes some texts from the original Slic3r documentation and from Bob's Project Notebook.

                  Was this article helpful?
                  This action is available only to registered users. Please log-in.

                  1 comment

                  Log in  to post a comment
                  aczekajski
                  •
                  TLDR:
                  Your program must read the gcode from file passed as last arg and write results to the same file.

                  Each line of the "Post-processing scripts" will be run as a terminal command with the gcode filepath added at the end (as a last arg):
                  "node foo.js --bar" will be run as "node foo.js --bar /path/to/the/input.gcode".
                  Reply

                  Topics

                  • PrusaSlicer 2.9 (Legacy)
                    • Advanced features
                      • Per model settings
                      • Color change
                      • Modifiers
                      • Reload from disk
                      • Insert pause or custom G-code at layer
                      • Negative volume
                      • Simplify mesh
                      • Post-processing scripts
                      • Shape Gallery
                      • Compare presets
                      • G-code substitutions
                      • Text tool
                      • SVG embossing tool
                      • Pressure Advance
                    • About PrusaSlicer
                    • Configuration and profiles
                    • User interface
                    • Input/output
                    • Left toolbar
                    • Top toolbar
                    • Print settings
                    • Filament settings
                    • Printer settings
                    • Multi-material slicing
                    • SLA slicing
                    • Other (PrusaSlicer)