Book Image

Instant Slic3r

By : David Moore
Book Image

Instant Slic3r

By: David Moore

Overview of this book

One of the most critical parts of 3D printing is taking a 3D model and converting it to a format that a 3D printer can print. Slic3r is one of the best pieces of software out there. It gives great control over how an object is converted, and can save you hours upon hours of frustration by producing great prints. This book will show you how. Instant Slic3r strives to give you a good foundation for what Slic3r can do. It offers a hands-on way to learn about how Slic3r works, and how you can use its powerful features to produce great prints. It takes you from the beginning setup, through advanced features such as post processing the G-Code that it produces. You will get a good grasp on how Slic3r works, and ways to troubleshoot your prints to make the best objects your printer can produce. Instant Slic3r covers where to get Slic3r and how to install it on a variety of platforms, and helps lead you through the setup and tweaking your personal printer settings. The book is clearly laid out and easy to follow, but with information that even experienced users of Slic3r will find useful. You will learn how Slic3r converts your model into G-Code. Then, you will learn how to not only read that G-Code, but how you can write scripts for post-processing the output, before it is sent to the printer. You will also learn what things can go wrong with printing, and how you can use Slic3r to troubleshoot the issue and then fix it. Along with this, you will learn how to improve your printing by delving into Slic3r's expert settings. The book is filled with examples, leading you through not only how to do things, but why they need to be done. After you are finished with this book, you will have a deeper understanding of Slic3r and 3D printing.
Table of Contents (7 chapters)

Post processing with Slic3r (Become an expert)

Our models aren't always perfect. Sometimes when we slice a model, there are issues with interpreting its geometry. Sometimes we just want to play around with the G-code to see how it will affect the model and print. That is where post processing comes in.

We can set up Slic3r to automatically run a post-processing script on our sliced model. Post-processing scripts can do things such as removing stray lines from the model to reducing the chance of blobbing on some surfaces; or even calculating the weight of filament that is needed to produce the model and give us the cost for that model in materials.

Getting ready

For this example, we will use one of the scripts put together by the developers of Slic3r to compute the cost of the filament used. The example script is in Euros, and the cost is just an example. To get the cost, we will need to change the units later, calculate the cost of the filament we are actually using, and put it into the script. For now though, we will go with the default script.


For Windows users, the current post-processing scripts are written in Perl. Users will need to install Perl in order to run these post-processing scripts.

How to do it...

  1. Get the script from the Slic3r GitHub at

  2. In the Print Settings tab, select Output options.

  3. In the Post-processing scripts section, input the absolute path to the script we are running. For example, on Windows, use C:\Slic3r\scripts\

  4. Slice the file. In this case we are using the Snake example again.

  5. Once the slicing is finished and if we open the file, we will find the following at the end of the file:

    ; filament used = 681.3mm (4.8cm3 or 6.00g PLA/5.04g ABS)
    ; costs = EUR 0.30 (PLA), EUR 0.10 (ABS)

    This is different from the original G-code file ending of:

    ; filament used = 681.3mm (4.8cm3)


If using a Windows machine gives an error, or the output G-code file does not change when the post-processing script is run, a change has to be made to the post-processing script.

Windows machines have limitations on how many processes can access a file at the same time. To get around this, we can make a backup file of the original and then run our process on the original. To do this we add $^I = '.bak'; before the While loop in the PERL script.

There's more...

A good idea is to keep all of our scripts in one place. A scripts folder inside the Slic3r folder is a good place, or you can place it in our user directory. When updating Slic3r, make sure that we back up the folder before installing the new version.

Each script must be executable by the host system, and must be a script that the host system can run. As noted previously, Perl isn't on Windows by default, so it would need to be installed. However, other scripting languages could be used by Slic3r.

Post processing scripts are passed the full path to the sliced file. Slic3r configuration options are available to post-processing scripts as environment variables that start with SLIC3R_.

Because post-processing scripts are able to call anything they normally could, it is even possible to make calls to a server and pass along data for the server to store or do other things with.

As mentioned in the previous section, the scripts don't have to be all in Perl. It just happens to be the language that the developers prefer, and that Slic3r itself is written in.

For Linux and Mac users, we can use shell scripts to call other programs, or do processing itself.

For Windows users, the basic batch file can be called.

If we need arguments passed to the script, Slic3r cannot do that. We would need to create another script for Slic3r that wraps our original script. That script would then call our original script with the arguments we want.