Is it possible to set a conditional z offset based on either filament type, nozzle temp or bed temp?
I’ve just got my probe height dialled in for pla and I’m about to switch to some petg for some tougher prints. I know that petg needs a different level of first layer squash to pla so can I set my start gcode to amend my offset based on the filament being used.
Something like if filament = petg z offset= a value
You could use SET_GCODE_OFFSET Z={Z_OFFSET} in your start gcode where Z_OFFSET is just taken from a LuT which set’s it depending on the passed filament type from the slicer
I put this in my print start macro: {% set FILAMENT_PROFILE = params.FILAMENT_PROFILE|default('none')|string %} to which I pass the filament type in my slicer, then you basically do this:
{% if FILAMENT_PROFILE == 'PLA' %}
{% set Z_OFFSET = <whatever you want it to be>|float %}
{% elif FILAMENT_PROFILE == 'ABS' %}
{% set Z_OFFSET = <whatever you want it to be>|float %}
... and so on for every filament type you want to cover
{% else %}
{% set Z_OFFSET = <default value>|float %}
{% endif %}
The |float is not really nescessary, I just prefer to have static typing wherever possible
Digging in on this, I had a hard time with Klipper not liking my macro, seemed to be the period in “.5” that I was trying to set for PC Z offset, but in the course of that I came across the following from here:
SET_GCODE_OFFSET [X=<pos>|X_ADJUST=<adjust>] [Y=<pos>|Y_ADJUST=<adjust>] [Z=<pos>|Z_ADJUST=<adjust>] [MOVE=1 [MOVE_SPEED=<speed>]]: Set a positional offset to apply to future G-Code commands. This is commonly used to virtually change the Z bed offset or to set nozzle XY offsets when switching extruders. For example, if “SET_GCODE_OFFSET Z=0.2” is sent, then future G-Code moves will have 0.2mm added to their Z height. If the X_ADJUST style parameters are used, then the adjustment will be added to any existing offset (eg, “SET_GCODE_OFFSET Z=-0.2” followed by “SET_GCODE_OFFSET Z_ADJUST=0.3” would result in a total Z offset of 0.1). If “MOVE=1” is specified then a toolhead move will be issued to apply the given offset (otherwise the offset will take effect on the next absolute G-Code move that specifies the given axis). If “MOVE_SPEED” is specified then the toolhead move will be performed with the given speed (in mm/s); otherwise the toolhead move will use the last specified G-Code speed.
This seems to be a more “built-in” way and I thought I would add to this thread for future use. Here’s my settings that I’m testing now:
Machine start Gcode to capture the filament type (I’m using Orca Slicer) -
START_PRINT BED=[bed_temperature_initial_layer_single] HOTEND=[nozzle_temperature_initial_layer] FILAMENT_PROFILE=[filament_type]
Parameter set in my START_PRINT macro -
Set up to adjust z offset depending on the filament type; from Conditional z offset
{% set FILAMENT_PROFILE = params.FILAMENT_PROFILE|default(‘none’)|string %}
Gcode conditions loaded after homing is performed - #Adjust filament Z offset AFTER homing
{% if FILAMENT_PROFILE == ‘PC’ %}
SET_GCODE_OFFSET Z=0.5
{% elif FILAMENT_PROFILE == ‘PLA’ %}
SET_GCODE_OFFSET Z=0
{% elif FILAMENT_PROFILE == ‘ASA’ %}
SET_GCODE_OFFSET Z=0
{% else %}
SET_GCODE_OFFSET Z=0
{% endif %}
Please make sure you test and any additional input greatly appreciated…I’m terrible at anything having to do with coding.
I’m still working on this, but it would make more sense to have it based on temperature rather than filament profile no? you could then use it with any slicer, and would only need to map some temperatures to offsets and generate the equation for this. It would also mean that whenever you change your “normal” z offset, the others would follow as well, without having to be reprobed. Of cours this only works if you don’t care about the first layer squish of different materials (which to be fair have never used).
True, but cura for example doesn’t have a material placeholder, whereas every slicer has a first layer extruder temperature one. That was my hypothesis on why this would be better