Running Slic3r from the command line (Become an expert)
Some of us like our GUIs, but some of us yearn for the control and options that only the command line can give. The creators of Slic3r are our kind of people. They've built in command line usage into Slic3r from the early stages of the project.
So far we have created prints from the graphical interface. Slic3r can also be controlled and tweaked from the command line, which gives the user more power and control over the printing process.
Getting ready
So now that we know about the command line, how do we get to it?
Windows:
Open a command window and navigate to the directory where we uncompressed Slic3r.
At the command prompt type
slic3r-console.exe
.
Mac:
Open a terminal window and navigate to the directory where Slic3r is installed.
At the prompt type
slic3r.pl -help
.
Linux:
Open a terminal window and navigate to the directory where Slic3r is installed.
At the prompt type
slic3r.pl -help
.
We'll now see the list of Slic3r commands that are available to us. If you'd like to look at the list, they are listed in the How it works... section of this recipe.
Note
One caveat for these instructions: As of the time of this writing, the Windows version of slic3r-console
has a bug in it. We can substitute slic3r.exe
to slice from the command line, but it will not have any console output.
How to do it...
Because Slic3r command line options are normally built in one line, we'll be splitting out the options into separate steps. At the end, we'll put it all together to run.
Note
The Windows command is different from the Mac and Linux version. We'll be demonstrating the Linux and Mac command, just substitute slicer-console
in for slicer.pl
.
Load in our current configuration using the following command:
slicer.pl --load <config filename>
Add in our options. In this case, changing the size of our object to twice the size:
--scale 2
Finally, we give Slic3r the name of our model:
<modelFilename.stl>
Slic3r will take the file, scale it up 200 percent as it slices it, and then output our file to modelFilename.gcode
.
Note
This method could be used to automate our printing process, batch slice a variety of files, and even process one file for a multitude of printer configurations.
How it works...
So now that we've looked at some things we can do with the command-line options, the ideas for what else we can do are starting to come to mind. The command-line options can be called from the programs we write, or set up to run later using the scheduling in Windows or cron on Linux and Mac. We can also set up web pages or mobile apps to call Slic3r.
The following is a list of what we see when we list out the help for Slic3r. There are wealth of options available to us. Look through it, and ideas for how to use Slic3r from the command line will continue to flow:
Slic3r 0.9.10b is a STL-to-GCODE translator for RepRap 3D printers written by Alessandro Ranellucci <aar@cpan.org> - http://slic3r.org/ Usage: slic3r.pl [ OPTIONS ] file.stl
This first section of the help is the general options, allowing us to check the version, to load and save configuration files, and even specify the number of processor threads that Slic3r can use. The following table lists them out:
|
Outputs this usage screen and exits |
|
Outputs the version of Slic3r and exits |
|
Saves the configuration to the specified file |
|
Load the configuration from the specified file. It can be used more than once to load options from multiple files. |
|
File to output G-code to (by default, the file will be saved into the same directory as the input file using the |
|
Number of threads to use (1+, default: 2) |
The output options are exactly what it says, the different settings we can use for output. This includes post processing, svg export, and merging multiple files into a single print.
Output option: | |
---|---|
|
The output filename format; all config options enclosed in brackets will be replaced by their values, as well as |
|
Generated G-code will be processed with the supplied script; call this more than once to process through multiple scripts. |
|
Export a SVG file containing slices instead of G-code. |
|
If multiple files are supplied, they will be composed into a single print rather than processed individually. |
Here is where we can tell Slic3r about our printer: the physical sizes, and what type of G-code that Slic3r should expect.
Printer options | |
---|---|
|
Diameter of nozzle in mm (default: |
|
Coordinates in mm of the point to center the print around (default: |
|
Additional height in mm to add to vertical coordinates (+/-, default: |
|
The type of G-code to generate ( |
|
Enable this to get relative E values |
|
Use G2/G3 commands for native arcs (experimental, not supported by all firmware) |
|
Use G0 commands for retraction (experimental, not supported by all firmware) |
|
Make G-code verbose by adding comments (default: |
|
Limit the frequency of moves on X and Y axes (Hz, set zero to disable; default: |
Filament options gives us finer control over how Slic3r will handle our plastic that we are printing with. We can change the first layer's temperature compared to the later layers, what the bed temperature should be, and what diameter filament we are using.
Filament option | |
---|---|
|
Diameter in mm of your raw filament (default: |
|
Change this to alter the amount of plastic extruded. There should be very little need to change this value, which is only useful to compensate for filament packing (default: |
|
Extrusion temperature in degree Celsius; set 0 to disable (default: |
|
Extrusion temperature for the first layer in degree Celsius; set 0 to disable (default: same as |
|
Heated bed temperature in degree Celsius; set 0 to disable (default: |
|
Heated bed temperature for the first layer, in degree Celsius, set 0 to disable (default: same as |
Speed options is where we can make our prints run faster, but if we aren't careful we will sacrifice quality. Some areas, such as gap filling, we may want to run faster, so there is less chance of sagging.
Speed options | |
---|---|
|
Speed of non-print moves in mm/s (default: |
|
Speed of print moves for perimeters in mm/s (default: |
|
Speed of print moves for small perimeters in mm/s or % over perimeter speed (default: |
|
Speed of print moves for the external perimeter in mm/s or % over perimeter speed (default: |
|
Speed of print moves in mm/s (default: |
|
Speed of print moves for solid surfaces in mm/s or % over infill speed (default: |
|
Speed of print moves for top surfaces in mm/s or % over solid infill speed (default: |
|
Speed of support material print moves in mm/s (default: |
|
Speed of bridge print moves in mm/s (default: |
|
Speed of gap fill print moves in mm/s (default: |
|
Speed of print moves for bottom layer, expressed either as an absolute value or as a percentage over normal speeds (default: |
Depending on the physical stability of our printer, adding in acceleration with these options can help speed up and improve the quality of our print.
Acceleration options | |
---|---|
|
Overrides firmware's default acceleration for perimeters. (mm/s^2, set zero to disable; default: |
|
Overrides firmware's default acceleration for infill. (mm/s^2, set zero to disable; default: |
|
Acceleration will be reset to this value after the specific settings have been applied. (mm/s^2, set zero to disable; default: |
Accuracy options is a little misleading. While adjusting layer height does usually yield smoother prints, adding in infill can also make the print sturdier.
Accuracy options | |
---|---|
|
Layer height in mm (default: |
|
Layer height for first layer (mm or %, default: |
|
Infill every N layers (default: |
|
Force a solid layer every N layers (default: |
Print options is also confusing at first, because it sounds like a catch-all category. These are the actual settings for the object to be printed: if it should have a solid top or bottom, how dense the fill material will be, and also allow us to use custom G-code for the start and end of the print.
Print options | |
---|---|
|
Number of perimeters/horizontal skins (range: 0+, default: |
|
Number of solid layers to be done for top surfaces (range: 0+, default: |
|
Number of solid layers to be done for bottom surfaces (range: 0+, default: |
|
Shortcut for setting the preceding two options at once |
|
Infill density (range: 0-1, default: |
|
Infill angle in degrees (range: 0-90, default: |
|
Pattern to use to fill non-solid layers (default: |
|
Pattern to use to fill solid layers (default: |
|
Load the initial G-code from the supplied file. This will overwrite the default command (home all axes [G28]). |
|
Load the final G-code from the supplied file. This will overwrite the default commands (turn off temperature [M104 S0], home X axis [G28 X], disable motors [M84]). |
|
Load |
|
Load |
|
Add more perimeters when needed (default: |
|
Randomize the starting point across layers (default: |
|
Disable retraction when travelling between infill paths inside the same island (default: |
|
Force solid infill when a region has a smaller area than the current threshold (mm^2, default: |
When we use support material, the following are the settings we would want to adjust. These tell Slic3r to use a support material or not, and where.
Support material options | |
---|---|
|
Generate support material for overhangs |
|
Overhang threshold angle (range: 0-90, set 0 for automatic detection, default: |
|
Pattern to use for support material (default: |
|
Spacing between pattern lines (mm, default: |
|
Support material angle in degrees (range: 0-90, default: |
Since the extruder is making the plastic filament more liquid, we will sometimes need the extruder to run backward, pulling the plastic back in so we don't get blobbing and dripping.
Retraction option | |
---|---|
|
Length of retraction in mm when pausing extrusion (default: |
|
Speed for retraction in mm/s (default: |
|
Additional amount of filament in mm to push after compensating retraction (default: |
|
Only retract-before-travel moves of this length in mm (default: |
|
Lift Z by the given distance in mm when retracting (default: |
If we are using multiple extruders, we definitely want to retract the plastic of the extruder that just finished so that it doesn't drip or dribble over the new plastic from the other extruder.
Retraction options for multi-extruder setups | |
---|---|
|
Length of retraction in mm when disabling tool (default: |
|
Additional amount of filament in mm to push after switching tool (default: |
Having the print sag, pop off the build platform and having gaps between layers can all be related to improper cooling. Slic3r gives us good controls over the cooling of the print with the following settings:
Cooling options | |
---|---|
|
Enable fan and cooling control |
|
Minimum fan speed (default: |
|
Maximum fan speed (default: |
|
Fan speed to use when bridging (default: |
|
Enable fan if layer print time is below this approximate number of seconds (default: |
|
Slow down if layer print time is below this approximate number of seconds (default: |
|
Minimum print speed (mm/s, default: |
|
Disable fan for the first N layers (default: |
|
Keep fan always on at min fan speed, even for layers that don't need cooling |
If we need to pre-extrude some plastic before printing the object, or have Slic3r add a brim to help the model stick to the platform, the following are the settings we will use.
Skirt options | |
---|---|
|
Number of skirts to draw (0+, default: |
|
Distance in mm between the innermost skirt and the object (default: |
|
Height of skirts to draw (expressed in layers, 0+, default: |
|
Generate no less than the number of loops required to consume this length of filament on the first layer, for each extruder (mm, 0+, default: |
|
Width of the brim that will get added to each object to help adhesion (mm, default: |
We can change the size and position of the object we want to print, without going back to edit the model. Using the two duplicate settings, we can even print several copies of the same object at the same time.
Transform options | |
---|---|
|
Factor for scaling input object (default: |
|
Rotation angle in degrees (0-360, default: |
|
Number of items with auto-arrange (1+, default: |
|
Bed size, only used for auto-arrange (mm, default: |
|
Number of items with grid arrangement (default: |
|
Distance in mm between copies (default: |
Sometimes we want to finish a whole object in a print file before moving on to the next one in the file. We need to be careful about where the extruder head goes so that it doesn't hit any of the objects. Also, having one of the parts done while the others print can sometimes be just what we need.
Sequential printing options | |
---|---|
|
When printing multiple objects and/or copies, complete each one before starting the next one; watch out for extruder collisions (default: |
|
Radius in mm above which the extruder won't collide with anything (default: |
|
Maximum vertical extruder depth; that is, the vertical distance from the extruder tip and carriage bottom (default: |
If we want to add in some comments to the output file, such as the date it was printed, what printer settings were used, even notes to ourselves on why we used the settings we did, we can put those in using the following option:
Miscellaneous options | |
---|---|
|
Notes to be added as comments to the output file |
The following are fairly advanced options, dealing with how wide the Slic3r will make the extrusion layer, if it should have a different first layer, and even have a different width between the perimeter and infill:
Flow options (advanced) | |
---|---|
|
Set the extrusion width manually; it accepts either an absolute value in mm (such as |
|
Set a different extrusion width for the first layer |
|
Set a different extrusion width for perimeters |
|
Set a different extrusion width for infill |
|
Set a different extrusion width for support material |
|
Multiplier for extrusion when bridging (> 0, default: |
Previously, we had some multi-extruder options with the retraction settings. These settings round out the other settings that we need to use with more than one extruder.
Multiple extruder options | |
---|---|
|
Offset of each extruder, if firmware doesn't handle the displacement (can be specified multiple times, default: |
|
Extruder to use for perimeters (1+, default: |
|
Extruder to use for infill (1+, default: |
|
Extruder to use for support material (1+, default: |
There's more...
There are many things that we can do with access to the command line. Every system that it runs on is capable of running a timed process, or a batch process.
So let's think about a few things we could do by using the command line. We could make a process that accepts models from the Web and automatically slices them and start a print remotely. We could even set up a webcam to watch the print in progress.
Taking that one step further, we could have other people upload their models. A Slic3r script could then calculate the amount of plastic needed and charge them for the print. They could watch the print on the webcam and see the results even before we put it in the mail to deliver.
That's just one idea of what we could do with access to the command line. Just like having your own 3D printer at your disposal, the sky is the limit for what we can do with Slic3r.