Scripting

Pathio lets you add bits of Gcode to different parts of your slice. This can let you pre-heat your nozzle before printing, home afterwards, or do more complicated actions when printing with more than one HotEnd.

Scripting Variables

See the full list of variables here.

In your scripts you can insert values you set in the configure tab. For example, you probably want to pre-heat your HotEnd to its printing temperature. To do this you would add the following lines to your starting script:

M104 S{{ nozzle_temp_0 }} ; Preheat Tool 0

In this case, {{ nozzle_temp_0 }} would be replaced in the actual Gcode generated by Pathio by the temperature you set in the Temperature Tab (perhaps 215). You can do this with almost every slicing setting in Pathio.

If you misspell a variable Pathio will currently skip all variables in the script where you made the mistake, not just the one that has a problem with it.
Pathio cannot ask your printer to report back values for these variables. Instead, these variables are replaced with "guesses" that Pathio makes while slicing, about what should be happening during your print. For example, the temperature-related variables won’t get the actual temperature of your printer, they’ll only be replaced with what you set your temperatures to be in Pathio. If your printer cools down for some unknown reason, these variables won’t be able to detect it.

Conditions

Scripts in Pathio can include conditional statements. For example, you could turn on a fan if your nozzle is set to more than 250°C:

{% if nozzle_temp_0 >= 250 %}
M106 S255 ; Turn fan on if HotEnd is Hot
{% endif %}

Another example would be to turn the fan off at a certain Z-height:

{% if state/Z == 10.0 %}
M106 S0 ; Turn fan off at Z = 10.0
{% endif %}

You can even do simple maths:

M104 S{{ addition(nozzle_temp_0, 10) }} ; Increase HotEnd temperature by 10 deg
G1 X10 Y10                              ; Move to a spot
G1 E10                                  ; Extrude a little bit
M104 S{{ subtract(nozzle_temp_0, 25) }} ; Set a lower-than-normal temperature while wiping the nozzle
G1 X25                                  ; Wipe nozzle
M104 S{{ nozzle_temp_0 }}      ; Set HotEnd temperature back to normal

Scripting Locations

You can script at the following locations:

Starting Gcode

This code will be added before your printer prints your actual model. Use the starting Gcode to preheat your printer, home it, and prime the nozzle.

Ending Gcode

This code is added at the very end of your Gcode file, after your whole object is finished printing. Use ending Gcode to cool down your printer and home it to avoid stringing and blobbing.

Layer-Change Script

This code is added in after each layer is finished printing.

Tool Change Script

This code describes a tool change. The tool change will not occur unless it happens in this script. By default this will handle tool changes normally, but will be completely overwritten if you add any gcode to the script.

Retract Script

This code describes a retraction move, and will be added whenever a retraction is set to take place. A retraction will not occur unless it happens in this script. By default this will handle retractions normally, but will be completely overwritten if you add any gcode to the script.

Unretract Script

This code describes the un-retract that happens when the printer resumes extruding after a retraction move. By default this will handle unretractions normally, but will be completely overwritten if you add any gcode to the script.

Z-hop Script

This code describes a Z-hop and will be added whenever a Z-hop is necessary. By default this will handle Z-hops normally, but will be completely overwritten if you add any gcode to the script.

Un-Z-hop Script

This code describes the un-Z-hop that happens when the printer resumes printing after a Z-hop. By default this will handle the aftermath of a Z-hop normally, but will be completely overwritten if you add any gcode to the script.

Pre-shell Script

This code is inserted before the shell of your object is printed (on each layer).

Post-shell Script

This code is inserted after the shell of your object is printed (on each layer).

Post-bed-adhesion Script

This code is inserted after the brim, raft, and skirt are finished.

See the full list of variables here.