Live adjustment of nozzle and filament diameters

I’ve got a working Klipper branch with a SET_EXTRUDER_NOZZLE_DIAMETER and SET_EXTRUDER_FILAMENT_DIAMETER that allow “live” changes of the nozzle and filament diameters!

pedrolamas/klipper at pedrolamas/nozzle-filament-diameters (

Right now, the only use-case I can think for something like this would be an E3D Revo nozzle being changed mid-print to a different nozzle size - although this would only make sense on a Voron Tap style toolhead so one could reset offset after changing the nozzle!

Is this something anyone here would be interested in? What other use-cases would you see such a feature being used?

1 Like

Nice idea!

But keep in mind that you have to change the sliced file too… :wink:

True, but I would assume that anyone using this would have thought of that, and so sliced part of the model with nozzle A, then send an M600 or PAUSE command to change be able to change nozzle, and then slice the rest of the model with nozzle B!

Thanks for doing this! I’d like to get this change-nozzle functionality into klipper.

FWIW I have a plugin that does this which you can install right now: GitHub - garethky/change-nozzle-klipper-extra: klipper extra that swaps nozzles without a reboot

It has the added benefit that the nozzle setting is stored in save variables and remembered between printer restarts.

I suppose I could re-implement the auto save/restore feature with macros, but I wish we could start submitting things that makes the printer smarter and saves this stuff automatically. I have the same thing for filaments: GitHub - garethky/filaments-klipper-extra: A Klipper plugin that does basic filament management for extruders in the printer so I no longer have a use for thermal presets. E.g. my printer remembers it has ABS loaded and can heat the nozzle and bed without needing additional input from me. It can run a PA calibration for the installed nozzle and filament type from a cold start with zero manual input.

We generally leave the work of making a “smart” printer to users and as a result klipper printers tend to end up more “dumb” than other printers, even though klipper is far more capable.

On second thought, if you get this shipped I’ll just override it and let my plugin live on.

Gawd Yes. I’m still pretty new to Klipper and putting it through it’s paces. I started using it on an Ender 2 Pro with a Sonic Pad, then the Sonic Pad on a newly build Voron 2.4 (350) and now Klipper on a LibreComputer. This is my first nozzle change (.4 to 1mm) in the 2 months I’ve been using Klipper and I came across the “Move exceeds maximum extrusion (0.663mm^2 vs 0.640mm^2)” error. Most of the solutions, including klipper log itself, suggest changing the “max_extrude_cross_section” which is non-existent in my printer.config. Another suggested changing the nozzle diameter and I was very confused that there wasn’t a setting to change that on the fly.

All that to say thanks @pedrolamas for the fork. I’ll eventually try that once I am comfortable with my new set up; and thanks @garethky for the plugin that I can attempt to use now.

1 Like

What does Klipper do with the nozzle diameter? I’ve used nozzles from .2mm to 1mm and never changed that setting in the firmware.

Only calculating the safety limits for extrusion. See Move exceeds maximum extrusion (AA mm^2 vs BB mm^2) for the math behind it.

Ah, right. I rely on extruders to do non-extrusion filament handling so I had to “bypass” this a while back by setting the “max_extrude” parameters to comically high values.

EDIT: So I guess that would be another use case for this feature! It might be beneficial to be able to set a “dummy” nozzle value to whatever would permit a G1 E600 F2000 to succeed and then change it back to the “real” value when actually printing.

Do you mean for something like filament loading on a Bowden system? You can set max_extrude_only_velocity and friends to do that kind of thing.

Right. I have them all set to 1000 and that works fine for my purposes, but it also means I’m essentially disabling the entire function this thread is about.

I strongly encourage everyone NOT to mess max_extrude_only_velocity et al., effectively disabling these sanity checks BUT if you are an experienced 3D printer and Klipper user then I usually would think that these checks is of minor importance.

(I should have never written the above, since everybody who managed to install Klipper and adding 150 macros to his config thinks he is an experienced user, but so be it)


I 1000% agree with you.

:warning: Those values are there for a reason, changing to insane values can render your printer unsafe to use!

The max_extrude_only_* values are there for moves that don’t involve an X/Y component. i.e. you are not printing. Then its safe to assume you are doing some sort of “filament handling” task, like loading filament into a bowden system. Then it seems valid to exceed an extruder movement speed that would otherwise cause an issue in a print. So the protections are relaxed, these are the settings for relaxed protections.

max_extrude_cross_section is the value that’s checked during X/Y moves that extrude. The extrude_only ones are ignored. This protects you from the slicer sending crazy gcode to the extruder during a print. This is the one you don’t want to mess with. You should set an accurate nozzle_diameter instead (they get multiplied together). That’s why making switching nozzle diameter easy is the right thing to do.

I have 5 use-cases for this easy nozzle switching:

  1. You don’t set max_extrude_cross_section to a high value, essentially disabling the protection, because its too cumbersome to switch the nozzle diameter in the config and restart the printer every time you swap nozzles.
  2. Check the nozzle diameter of the print against the nozzle installed in your PRINT_START macro. Just pass the nozzle_diameter_* placeholder to your PRINT_START macro, check and throw an error. “This print requires a 0.6mm nozzle but you have a 0.4mm nozzle installed”. (Prusa Slicer is missing the placeholder for this but SuperSlicer has it)
  3. Front ends (Fluidd/Mainsail) already extract the nozzle diameter of a print from the metadata block. Now you can refuse to print a file if the nozzle installed is incorrect.
  4. Purge Line macros can use the nozzle diameter to extrude appropriate amounts of filament for that nozzle so they don’t violate max_extrude_cross_section
  5. Calibration print macros (e.g. PA_CAL) can use the nozzle diameter from the extruder instead of asking you for it. (With filament presets this results in calibration macros that take no arguments, making them 1 click to run)

I’m with you. Unfortunately, AFAIK, Klipper doesn’t currently have any way of knowing that the extruder is simply loading filament from the spool into the hotend, not actually extruding filament through the nozzle, so the only way to get it to do that at a reasonable speed is to set these parameters to insane values.

But I think your proposal in this thread could provide a way to leave these settings at reasonable values for normal printing, but set dummy nozzle values for filament-handling operations that will monkey with the math to permit these operations, then restore the actual nozzle size before returning to normal printing.