Skip to main content
Version: 2.0.x

Configuring RatOS Macros

RatOS comes with a bunch of flexible predefined macro's that can be customized via variables and macro hooks.

Variables

In your printer.cfg at the bottom of the Macro's section, you'll notice this:

printer.cfg
##########################################
### MACRO CONFIGURATION
### Configure the behavior...
##########################################
[gcode_macro RatOS]
....

This is a macro that serves as a place to store variables that all the RatOS macro's refer to when they're executed. Since they're gcode variables you can change them on the fly, for example from your slicer's custom gcode sections:

SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=relative_extrusion VALUE=True
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=preheat_extruder_temp VALUE=200

Not all of the available variables are listed in printer.cfg by default. If you want to change a variable that isn't in printer.cfg simply just add it under the [gcode_macro RatOS] section.

Below you'll find a list of the available variables and what they do.

Relative Extrusion

NamePossible ValuesDefault
variable_relative_extrusionTrue / FalseFalse

Controls which extrusion mode START_PRINT ends in. Which value you use here depends on your slicer configuration, in other words this variable should always correspond to the extrusion mode setting in your slicer. It is recommended to configure your slicer for relative extrusion and set this variable to True.

Speed

NamePossible ValuesDefault
variable_macro_travel_speednumber300
variable_macro_z_speednumber10

Travel speed to use for gcode moves in RatOS Macro's in mm/s.

Homing

NamePossible ValuesDefaultDescription
variable_safe_home_x"middle" / number"middle"The x coordinate for where to return the toolhead to when homing Z
variable_safe_home_y"middle" / number"middleThe y coordinate for where to return the toolhead to when homing Z
variable_homing_z_hopnumber15How much to raise the toolhead after homing Z. Probe configs may change this value.
variable_driver_type_xstring"tmc2209"The driver type used on X. Used to restore current after sensorless homing
variable_driver_type_ystring"tmc2209"The driver type used on X. Used to restore current after sensorless homing

Heating

NamePossible ValuesDefaultDescription
variable_preheat_extruderTrue / FalseTrueEnables or disables preheating of the nozzle to 150 degrees during the START_PRINT macro. There are several benefits to preheating the nozzle. 1) Gives the bed additional time to diffuse the heat. 2) Softens plastic that may be stuck in the nozzle so it doesn't block your probe from triggering. 3) If using a non thermally compensated inductive probe, it makes the temperature and thus the offset of the probe more predictable and consistent.
variable_start_print_heat_chamber_bed_tempNumber115The bed temperature to use when heating the chamber when the CHAMBER_TEMP parameter is supplied to the START_PRINT macro.
variable_preheat_extruder_tempNumber150The temperature to preheat the extruder to, to soften the material at the nozzle tip

Bed Mesh Calibration

NamePossible ValuesDefault
variable_calibrate_bed_meshTrue / FalseTrue

Whether or not to calibrate a bed mesh before each print. If you prefer calibrating your bed mesh manually instead of on each print, you can disable it by setting this to False. Disabling variable_calibrate_bed_mesh will stop RatOS from loading a bed mesh entirely. If you want it to load a mesh, you can set variable_bed_mesh_profile to the name of the profile you want it to load.

NamePossible ValuesDefault
variable_bed_mesh_profileundefined / stringundefined

Use this variable to set name for the bed_mesh profile that RatOS calibrate and loads. If variable_calibrate_bed_mesh is False you must set this variable to the profile name you wish to load, or no bed mesh will be loaded. If variable_calibrate_bed_mesh is True and this variable isn't set, RatOS will use ratos as the profile name.

Nozzle Priming

NamePossible ValuesDefaultDescription
variable_nozzle_priming"primeline" / "primeblob" / False"primeblob"Whether or not to prime the nozzle during the START_PRINT macro. "primeline" will make START_PRINT draw a short line to prime the nozzle. "primeblob" will put a small blob at the edge of the bed that is intended to wrap around the nozzle, then lifts the toolhead out of it while extruding a small line, effective for cleaning the nozzle and it's easy to clean up.
variable_nozzle_prime_start_x"min" / "max" / number"max"Where to place the primeline or blob in X. "min" starts the blob or line at x=0 + some safety margin. "max" starts the blob or line at x=max - some safety margin. If set to a number, that number will be used as the starting x coordinate of the line or blob.
variable_nozzle_prime_start_y"min" / "max" / number"min"Where to place the primeline or blob in Y. "min" starts the blob or line at y=0 + some safety margin. "max" starts the blob or line at y=max - some safety margin. If set to a number, that number will be used as the starting y coordinate of the line or blob.
variable_nozzle_prime_direction"auto" / "forwards" / "backwards"auto"The direction to draw the line or blob in, if "backwards" the toolhead will move toward the front of the printer, if "forwards" it will move towards the back. When set to "auto" it will move towards the middle regardless of variable_nozzle_prime_start_y.

Filament loading/unloading

NamePossible ValuesDefaultDescription
variable_filament_unload_lengthnumber130How much to retract in mm when unloading filament after the tip has been formed
variable_filament_unload_speednumber5How fast to retract the filament_unload_length filament in mm/s
variable_filament_load_lengthnumber100How much to extrude in mm when loading filament to get the filament to the nozzle
variable_filament_load_speednumber10How fast to extrude the filament_load_length in mm/s

Parking

NamePossible ValuesDefaultDescription
variable_start_print_park_in"back" / "center" / "front""back"Where to park the toolhead during final nozzle heating.
variable_start_print_park_xnumber / undefinedundefinedCustom X coordinate to park the toolhead during final nozzle heating.
variable_start_print_park_z_heightnumber50The z height at which to park the toolhead during final nozzle heating.
variable_end_print_park_in"back" / "center" / "front""back"Where to park the toolhead after ending or canceling a print.
variable_end_print_park_xnumber / undefinedundefinedCustom X coordinate to park the toolhead after ending or canceling a print.
variable_end_print_park_z_hopnumbernumberHow many mm to lift the nozzle when after ending or cancelling a print.
variable_pause_print_park_in"back" / "center" / "front""back"Where to park the toolhead when pausing a print.
variable_pause_print_park_xnumber / undefinedundefinedCustom X coordinate to park the toolhead when pausing a print.

Stowable probes

These variables are only relevant when using a stowable probe such as Euclid or Klicky. Use these to customize and finetune the deployment and stowing procedures.

NamePossible ValuesDefaultDescription
variable_stowable_probe_position_preflightTupleundefinedThe coordinates to move the toolhead to before the probe deployment routine. Example: [30, 60]
variable_stowable_probe_position_sideTupleundefinedThe coordinates to move the toolhead to before entering the dock during deployment, or exiting the dock while stowing. Example: [30, 0]
variable_stowable_probe_position_dockTupleundefinedThe coordinates of the toolhead when it's positioned perfectly inside the dock for pickup. Example: [0, 0]
variable_stowable_probe_position_exitTupleundefinedThe coordinates to move the toolhead to when exiting the dock while deploying or entering the dock while stowing. Example: [0, 60]

Skew profile

NamePossible ValuesDefaultDescription
variable_skew_profilestring or undefinedundefinedUse this if you have calibrated and saved a skew profile that you want to load in the START_PRINT macro. To activate it, set the variable to the name of your saved skew profile.

User macro hooks

These hooks do nothing by default, that means you can safely implement them in your USER OVERRIDES section without copy pasting anything from the RatOS config files, like so:

[gcode_macro _USER_START_PRINT_BED_MESH]
gcode:
SETUP_KAMP_MESHING

_USER_START_PRINT_BEFORE_HOMING

Runs before the printer homes at the start of START_PRINT.

_USER_START_PRINT_HEAT_CHAMBER

Runs right after the chamber has started heating, if CHAMBER_TEMP is supplied to START_PRINT.

_USER_START_PRINT_AFTER_HEATING_BED

Runs right after the bed has reached temp, before the internal _START_PRINT_AFTER_HEATING_BED

_USER_START_PRINT_BED_MESH

Runs before _START_PRINT_BED_MESH

_USER_START_PRINT_PARK

Runs before _START_PRINT_PARK

_USER_START_PRINT_AFTER_HEATING_EXTRUDER

Runs just before _START_PRINT_AFTER_HEATING_EXTRUDER

_USER_END_PRINT_BEFORE_HEATERS_OFF

Runs before the heaters are turned off in END_PRINT

_USER_END_PRINT_AFTER_HEATERS_OFF

Runs after the heaters are turned off in END_PRINT

_USER_END_PRINT_PARK

Runs before the toolhead is parked in END_PRINT

Internal macro hooks

These hooks are used internally, so if you override these be sure to copy paste the original implementation and modify that or you may break some functionality. Remember to check if there's an override in the printer's macro.cfg file, in which case that's the one you would copy.

_START_PRINT_HEAT_CHAMBER

Heats the chamber, if CHAMBER_TEMP is supplied to START_PRINT.

_START_PRINT_AFTER_HEATING_BED

Runs right after the bed has reached temp, after _USER_START_PRINT_AFTER_HEATING_BED. It is usually used for additional bed calibration, such as Z_TILT_ADJUST or QUAD_GANTRY_LEVELING depending on the printer.

_START_PRINT_BED_MESH

Handles bed meshing logic.

_START_PRINT_PARK

Parks the extruder while heating the nozzle to print temperature.

_START_PRINT_AFTER_HEATING_EXTRUDER

Primes the nozzle and loads the skew profile if any is defined in the RatOS variables.