Skip to main content
Version: 2.1.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 top, 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.

Printing

[gcode_macro RatOS]

NamePossible ValuesDefaultDescription
variable_relative_extrusionTrue / FalseFalseControls 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.
variable_force_absolute_positionTrue / FalseFalseForces absolute positioning before the print starts.

Speed

[gcode_macro RatOS]

NamePossible ValuesDefaultDescription
variable_macro_travel_speednumber300XY Travel speed to use for gcode moves in RatOS Macro's in mm/s.
variable_macro_travel_accelnumber2000XY Travel acceleration to use for gcode moves in RatOS Macro's in mm/s².
variable_macro_z_speednumber15Z Travel speed to use for gcode moves in RatOS Macro's in mm/s.

Homing

[gcode_macro RatOS]

NamePossible ValuesDefaultDescription
variable_z_probe"static" / "stowable""static"z-probe type
variable_homing"endstops" / "sensorless""endstops"axis homing method
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
variable_sensorless_x_currentnumber0.4stepper driver run current for sensorless x-homing
variable_sensorless_y_currentnumber0.4stepper driver run current for sensorless y-homing

Heating

[gcode_macro RatOS]

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_preheat_extruder_tempNumber150The temperature to preheat the extruder to, to soften the material at the nozzle tip

Bed Mesh Calibration

[gcode_macro RatOS]

NamePossible ValuesDefault
variable_calibrate_bed_meshTrue / FalseTrue
variable_adaptive_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

[gcode_macro RatOS]

NamePossible ValuesDefaultDescription
variable_nozzle_priming"primeblob" / False"primeblob"Whether or not to prime the nozzle during the START_PRINT macro. "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.
variable_nozzle_prime_bridge_fannumber102priming fan speed 0-255

Filament loading/unloading

[gcode_macro RatOS]

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

[gcode_macro RatOS]

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.

Toolhead configuration

[gcode_macro T0]

NamePossible ValuesDefaultDescription
variable_hotend_type"SF", "HF", "UHF"Nozzle type. used for loading/unloading macros.
variable_has_cht_nozzlenumberNozzle type. used for loading/unloading macros.
variable_cooling_position_to_nozzle_distancenumber40MM from the cooling position to the nozzles melting zone.
variable_tooolhead_sensor_to_extruder_gear_distancenumber15MM from the toolhead filament sensor trigger point to the extruder gears.
variable_extruder_gear_to_cooling_position_distancenumber30MM from the extruder gears to the cooling zone.
variable_filament_loading_nozzle_offsetnumber-5MM loading offset for fine tuning.
variable_filament_grabbing_lengthnumber5MM filament grabbing length when inserting filament into the extruder.
variable_filament_grabbing_speednumber1Filament grabbing speed.
variable_enable_insert_detectionTrue / FalseTrueEnable the filament sensor insert detection.
variable_enable_runout_detectionTrue / FalseTrueEnable the filament sensor runout detection.
variable_enable_clog_detectionTrue / FalseTrueEnable the filament sensor clog detection.
variable_unload_after_runoutTrue / FalseTrueUnload filament from toolhead after if runout has been detected.
variable_resume_after_insertTrue / FalseTrueAuto resume a paused print after runout and insert.
variable_purge_after_loadnumber0Purge x mm after the filament has been loaded to the nozzle tip.
variable_purge_before_unloadnumber0Purge x mm before the filament unloads.
variable_extruder_load_speednumber60Extruder/cooling zone loading speed.
variable_filament_load_speednumber10Filament nozzle loading speed.
variable_temperature_offsetnumber0Adds a positive or negative offset to the nozzle temperature.
variable_has_oozeguardTrue / FalseFalseToolhead has a oozeguard.
variable_has_front_arm_nozzle_wiperTrue / FalseFalseToolhead has a front arm nozzle wiper.
variable_loading_positionnumber0X-position for filament loading/unloading actions.
variable_parking_positionnumber0Toolhead parking x-position.

VAOC

[gcode_macro _VAOC]

NamePossible ValuesDefaultDescription
variable_is_fixedTrue / FalseFalseVAOC is installed on a fix position.
variable_safe_znumber60Safe z-height for xy travel moves.
variable_auto_z_offset_calibrationTrue / FalseTruePerforms a auto z-offset calibration before the print starts if needed.
variable_enable_camera_coolingTrue / FalseTrueEnables the part cooling fan of the currently loaded toolhead.
variable_camera_cooling_fan_speednumber0.3Part cooling fan speed of the currently loaded toolhead.
variable_camera_cooling_temperaturenumber50Enables the integrated VAOC fan at the configured bed temperature.
variable_toolchange_travel_speednumber300XY travel move speeds.
variable_toolchange_travel_accelnumber5000XY travel move sccelerations.

IDEX

[gcode_macro RatOS]

NamePossible ValuesDefaultDescription
variable_auto_center_subjectTrue / FalseFalseExperimental auto centering subject on build plate for copy and mirror mode.
variable_toolchange_zhopnumber2.0Toolshift z-hop.
variable_toolchange_zspeednumber25Toolshift z-hop speed.
variable_toolchange_sync_fansTrue / FalseFalseSynchronizes fan speeds while printing.
variable_toolchange_combined_zhopTrue / FalseFalseCombines z-hop and retract/deretract moves for toolshifts.
variable_toolchange_travel_speednumber300Toolshift travel speed.
variable_toolchange_travel_accelnumber5000Toolshift travel acceleration.
variable_toolchange_extrusionnumber2.0Toolshift deretraction.
variable_toolchange_retractionnumber2.0Toolshift retraction.
variable_toolchange_feedratenumber7200Extruder feedrate for retract/deretract moves for toolshifts.
variable_toolchange_prepurging_timernumber0Prepurge some filament before going back to the buildplate after X seconds of inactivity.
variable_toolchange_purgenumber25MM of filament that gets prepruged in case the timer has been configured,
variable_toolchange_standby_tempnumber-1If configured the toolheads are going into standby mode when parked.
variable_toolchange_first_purgenumber50MM of filament that gets purged before a toolheads first use.

Beacon probe

[gcode_macro RatOS]

NamePossible ValuesDefaultDescription
variable_beacon_bed_mesh_scvnumber25Square corner velocity for beacon proximity bed meshing.
variable_beacon_contact_z_homingTrue / FalseFalseUse beacon contact for z-homing.
variable_beacon_contact_z_calibrationTrue / FalseFalseUse beacon contact z-calibration.
variable_beacon_contact_calibration_locationnumber130Beacon contact z-calibration location.
variable_beacon_contact_calibrate_margin_xnumber30Beacon contact z-calibration x-margin.
variable_beacon_contact_bed_meshTrue / FalseFalseUse beacon contact for bed meshing.
variable_beacon_contact_bed_mesh_samplesnumber2Beacon contact bed mesh probe samples.
variable_beacon_contact_z_tilt_adjustTrue / FalseFalseUse beacon contact for z-tilting.
variable_beacon_contact_z_tilt_adjust_samplesnumber2Beacon contact z-tilt probe samples.
variable_beacon_contact_prime_probingTrue / FalseFalseUse beacon contact to probe for prime blobs.
variable_beacon_contact_calibration_tempnumber150Beacon contact z-calibration nozzle temperature.
variable_beacon_contact_expansion_compensationTrue / FalseFalseUse nozzle thermal expansion compensation.
variable_beacon_contact_expansion_multipliernumber1.0Multiplier for the nozzle thermal expansion compensation.

Stowable probes

[gcode_macro RatOS]

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

_USER_START_PRINT

Runs before the START_PRINT macro

_USER_END_START_PRINT

Runs after the START_PRINT macro

_USER_START_FEATURE

Runs at the start of a new print feature. This is useful for running custom G-Code based on the feature that is being printed.

_USER_END_FEATURE

Runs at the end of a print feature. This is useful for running custom G-Code based on the feature that is being printed.

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.

_END_PRINT_AFTER_HEATERS_OFF

Runs right after the heaters have been turned off in the END_PRINT macro.