Is there a plugin that would allow unloading the filament after a print?

Is there an existing plugin that I could configured somehow so that it would send the "unload filament" command after the print is finished? That is, a way I can say, "after the next print, unload the filament before the nozzle cools down."

Just for a specific print or for every print?

Specific prints. I envision it as an option you enable before you hit the "print" button. I would need to disable the option before the next print if I didn't want the filament unloaded.

Nothing I've seen currently has that option.

The prusa with mmu (multi tool changer) sends the unload command at the end of a print by default. That is done in the slicer and the MMU has a buffer and retractor that pulls the filament from the printhead after the extruder has pulled it from the hotend. So, that said, is a gcode command sufficient for removing the filament in your situation? is manual intervention required to remove your filament or is it automated?

I have an mk3s without the mmu, so unloading does not require manual intervention. That's why I figured having octoprint handle it would be convenient, because that way I can run my print unattended, and when the print is finished, the filament is ejected.

I've noticed a problem where sometimes the filament gets stuck in the ptfe tube if left alone after a print, so if I know that I'm not going to be printing anytime soon, I'd like to auto-eject the filament.

I suppose that this is a good opportunity for me to write my own plugin.

I'm not sure you need plugin. Go to OctoPrint Settings, GCODE Scripts, After print job completes, and add your code there. I'd surround it with an {% if true %} {% endif %} and then you just change true to false when you don't want to eject the filament.

If you want to go the plugin route, check out https://github.com/OctoPrint/OctoPrint-AutomaticShutdown. This plugin may have been abandoned. There's a procedure to follow to adopt abandoned plugins and that's what I would do instead of creating a plugin from scratch.

The OctoPrint Discord has some very active, very useful, and very knowledgeable people that could help you successfully adopt this plugin if you decided to go that route.

2 Likes

Another plugin to take a look at: https://github.com/google/OctoPrint-HeaterTimeout

In such cases I would just use the slicer to put the gcode to unload at the end of the files. You can make multiple profiles in the slicer, for example one with unload and one without unload.
Or you can just put the gcode in octoprint as suggested at the end of the print.
It can be as simple as using a line like 'G1 E-2000' at the end of the print or script (when the nozzle still hot enough).
Using it as a flagged plugin might also result in unloading when a print is cancelled before the end and that might not be what you want?

I definitely don't want this in the slicer because I don't want it to be a permanent part of the model. For one thing, my request to get this feature added to PrusaSlicer was rejected. Secondly, I want to be able to print a model three times, for example, but only after the third print (the last print of the day) do I want the filament ejected.

Looks like I'm going to have to write my own plugin.

I haven't tried it yet, but Custom Control can be used to create buttons and interact with parametrized GCode scripts. You could use this with a script you run automatically at the end of each print.
https://docs.octoprint.org/en/master/features/custom_controls.html#sec-features-custom-controls-examples-gcode-script

1 Like

What's the overall benefit of immediately unloading the filament? I think in the early days I actually had something like that in my end script gcode. More often than I cared, I would leave the printer for a day and come back to print something else, and get nothing, because the filament was "unloaded", although you obviously couldn't tell that from just looking at the printer. :slight_smile:

For me, I have a button in the Custom Control plugin that extrudes some filament, then does a quick retract to unload the filament so that I get a clean withdrawal from the nozzle, and any swelling at the nozzle is minimized. This is the script for my CR10, so Prusa would be a bit different.

G1 E30 F300 ; Extrude 20mm to warm the heatbreak filament
G1 E-10 F1600
G1 E-450 F3600

Obviously to each his own. My workflow works better for me to do these things at the front of the print job.

You might create gcode to do your extraction and then run that program whenever you want to eject the filament. I'll note that when the mmu retracts, it first pushes out 10mm or so, then retracts. This may help to prevent stringing and help to form the tip for the next load.

I remove the filament after my prints, so I can keep it safe from moisture when itś not in use. If you use Marlin, all you have to do is add M702 at your end GCODE script. it will unload your filament from the hotend. If you have a direct setup, it's straight forward, if you have bowden, you can configure the length of the pull and other parameters in your firmware configure_adv.h file. Search for ADVANCED_PAUSE_FEATURE in your file, and make the adjustments.

Mine as an example:

#define ADVANCED_PAUSE_FEATURE
#if ENABLED(ADVANCED_PAUSE_FEATURE)
  #define PAUSE_PARK_RETRACT_FEEDRATE         60  // (mm/s) Initial retract feedrate.
  #define PAUSE_PARK_RETRACT_LENGTH            2  // (mm) Initial retract.
                                                  // This short retract is done immediately, before parking the nozzle.
  #define FILAMENT_CHANGE_UNLOAD_FEEDRATE      8  // (mm/s) Unload filament feedrate. This can be pretty fast.
  #define FILAMENT_CHANGE_UNLOAD_ACCEL        25  // (mm/s^2) Lower acceleration may allow a faster feedrate.
  #define FILAMENT_CHANGE_UNLOAD_LENGTH      100  // (mm) The length of filament for a complete unload.
                                                  //   For Bowden, the full length of the tube and nozzle.
                                                  //   For direct drive, the full length of the nozzle.
                                                  //   Set to 0 for manual unloading.
  #define FILAMENT_CHANGE_SLOW_LOAD_FEEDRATE   5  // (mm/s) Slow move when starting load.
  #define FILAMENT_CHANGE_SLOW_LOAD_LENGTH    10  // (mm) Slow length, to allow time to insert material.
                                                  // 0 to disable start loading and skip to fast load only
  #define FILAMENT_CHANGE_FAST_LOAD_FEEDRATE   6  // (mm/s) Load filament feedrate. This can be pretty fast.
  #define FILAMENT_CHANGE_FAST_LOAD_ACCEL     25  // (mm/s^2) Lower acceleration may allow a faster feedrate.
  #define FILAMENT_CHANGE_FAST_LOAD_LENGTH    80  // (mm) Load length of filament, from extruder gear to nozzle.
                                                  //   For Bowden, the full length of the tube and nozzle.
                                                  //   For direct drive, the full length of the nozzle.
  //#define ADVANCED_PAUSE_CONTINUOUS_PURGE       // Purge continuously up to the purge length until interrupted.
  #define ADVANCED_PAUSE_PURGE_FEEDRATE        3  // (mm/s) Extrude feedrate (after loading). Should be slower than load feedrate.
  #define ADVANCED_PAUSE_PURGE_LENGTH         50  // (mm) Length to extrude after loading.
                                                  //   Set to 0 for manual extrusion.
                                                  //   Filament can be extruded repeatedly from the Filament Change menu
                                                  //   until extrusion is consistent, and to purge old filament.
  #define ADVANCED_PAUSE_RESUME_PRIME          0  // (mm) Extra distance to prime nozzle after returning from park.
  //#define ADVANCED_PAUSE_FANS_PAUSE             // Turn off print-cooling fans while the machine is paused.

                                                  // Filament Unload does a Retract, Delay, and Purge first:
  #define FILAMENT_UNLOAD_PURGE_RETRACT       13  // (mm) Unload initial retract length.
  #define FILAMENT_UNLOAD_PURGE_DELAY       5000  // (ms) Delay for the filament to cool after retract.
  #define FILAMENT_UNLOAD_PURGE_LENGTH         8  // (mm) An unretract is done, then this length is purged.
  #define FILAMENT_UNLOAD_PURGE_FEEDRATE      25  // (mm/s) feedrate to purge before unload

  #define PAUSE_PARK_NOZZLE_TIMEOUT           45  // (seconds) Time limit before the nozzle is turned off for safety.
  #define FILAMENT_CHANGE_ALERT_BEEPS         10  // Number of alert beeps to play when a response is needed.
  #define PAUSE_PARK_NO_STEPPER_TIMEOUT           // Enable for XYZ steppers to stay powered on during filament change.

  //#define PARK_HEAD_ON_PAUSE                    // Park the nozzle during pause and filament change.
  //#define HOME_BEFORE_FILAMENT_CHANGE           // Ensure homing has been completed prior to parking for filament change

  #define FILAMENT_LOAD_UNLOAD_GCODES           // Add M701/M702 Load/Unload G-codes, plus Load/Unload in the LCD Prepare menu.
  //#define FILAMENT_UNLOAD_ALL_EXTRUDERS         // Allow M702 to unload all extruders above a minimum target temp (as set by M302)
#endif