Scripts Tab

Scripts Tab

For advanced control of your 3D printer, Simplify3D® gives the option of writing custom G-code scripts to be inserted into the main code at specific points. In addition to regular G-code commands, Simplify3D® provides certain variables and macros for conditional programming. These include:

[previous_Z_position] - a variable that holds the previous layer's Z position value.

[current_Z_position] - a variable that holds the current (new) layer's Z position value.

[old_tool] - the old toolhead, replaced by T0 or T1 during code execution.

[new_tool] - the current (new) toolhead, replaced by T0 or T1 during code execution.

[fan_speed_pwm] - Fan speed on a PWM scale of 0 to 255, where 255 equals 100%.

[fan_speed_percentage] - Fan speed on a 0 to 100 numerical scale.

[extruderX_temperature] - Used for custom heating procedures. Replace X with 0 or 1, corresponding to T0 or T1.

[bed0_temperature] - Used for custom heating procedures. AON-M only has one bed, so bed0 is always used.

{IF NEWTOOL=X} - Conditional logic - the G-code immediately proceeding this (on the same line) will only be executed if the conditional holds true, otherwise it will go to the next line. Replace X with 0 or 1, corresponding to T0/T1.

{IF OLDTOOL=X} - Conditional logic - same as above except a conditional for the last toolhead activated instead of the new.

In G-code programming, a line break signifies the start of the next command, and a semicolon provides space for comments. Everything after a semicolon will be ignored until the next line break.

Starting Script

The Starting Script runs before the print begins but after heating. By default, Simplify3D® automatically appends the heating (M104/140) commands before every print, but you can customize the heating and homing behavior if you would like. This is a good place to apply things like custom PID values, toolhead offsets, or other configuration values without modifying the firmware’s hard-coded values.

Layer Change Script

The Layer Change Script runs between the end of layer and the beginning of the next. Potential uses for this include a nozzle wipe when using sticky/viscous materials.

Retraction Script

Overrides the G-code automatically generated by the retraction-related process settings.

Tool Change Script

Overrides the G-code automatically generated by the tool change-related process settings. With the AON-M2, tool change movements are handled by the firmware, so this section can be used to modify the tool change retraction values. The default script provided in all AON-M2 material profiles (.fff files) is given below.

{IF OLDTOOL=0} T1 S1
{IF OLDTOOL=0} G91 ;relative mode
{IF OLDTOOL=0} G1 E10 F60 ;purge 10
{IF OLDTOOL=0} G1 X-60 F10000 ;move T1 tool head to wipe
{IF OLDTOOL=0} G1 X30 F10000 ;move T1 tool head to wipe
{IF OLDTOOL=0} G1 X-30 F10000 ;move T1 tool head to wipe
{IF OLDTOOL=0} G1 X30 F10000 ;move T1 tool head to wipe
{IF OLDTOOL=0} G92 E0 ;reset extruder
{IF OLDTOOL=0} G90 ;absolute mode
{IF OLDTOOL=1} T0 S1
{IF OLDTOOL=1} G91 ;relative mode
{IF OLDTOOL=1} G1 E10 F60 T0;purge 10
{IF OLDTOOL=1} G1 X60 F10000 ;move T0 tool head to wipe
{IF OLDTOOL=1} G1 X-30 F10000 ;move T0 tool head to wipe
{IF OLDTOOL=1} G1 X30 F10000 ;move T0 tool head to wipe
{IF OLDTOOL=1} G1 X-30 F10000 ;move T0 tool head to wipe
{IF OLDTOOL=1} G92 E0 ;reset extruder
{IF OLDTOOL=1} G90 ;absolute mode

For single tool prints, ensure the Tool Change Script is empty. Simplify3D® will interpret the start of a print as a tool change and will run the Tool Change Script on the inactive toolhead, attempting to purge filament from a cold hot end.

Ending Script

This script runs after the last printing move. The default script for the AON-M2 is given below:

G28 X ;home X
M104 S0 T0 ;turn off T0 heater
M104 S0 T1 ;turn off T1 heater
M104 S0 T2 ;turn off chamber heater
M140 S0 ;turn off bed

Post Processing

Post-processing gives you access to scripting functionality directly within the Simplify3D® interface.

Below are some examples of the tools available:

{REPLACE "E" "A"} - search and replace for the text within quotes, in this example every "E" character would be replaced with an "A" character

{PREPEND "G92 E0\n"} - prepends the specified text at the very beginning of the G-code file, note that the \n is converted into a true newline character, not two separate "\" and "n" characters

{APPEND "G28 X0 Y0\n"} - appends the specified text to the very end of the G-code file

{DELETE "M82\n"} - deletes every occurrence of the specified text from the G-code file, note that it will not automatically delete a line if it is suddenly empty after the deletion, so that is why you might want to include the \n at the end (so that the empty line is also removed)

{STRIP ";"} - completely deletes every line in the G-code file that begins with the specified text

{TOOL0REPLACE "E" "A"} and {TOOL1REPLACE "E" "B"} - these special TOOL#REPLACE commands will do a search and replace, very similar to the {REPLACE} command, however, the replace only occurs if the specified tool is active. For example, when using TOOL1REPLACE, the replacement will only occur if tool 1 was currently active at that line of the G-code file

Last modified: April 9, 2024