Use Gcode Extrusion Speed in Calculations I have a Rostock Max V2, and I've added a second extruder going into a y-splitter into a single nozzle on my printer. I have both extruders working correctly, but I'm having trouble tuning the retraction settings to prevent stringing when I switch between extruders during a print.  My system is essentially identical to the setup seen here.  However, I can't get my printer to retract as cleanly as the one in the video

What I'm trying to avoid is the long, thin "tail" that forms when retracting the filament from the hot end. That "tail" binds the other filament during the switch and makes the extruder grind a hollow spot on the filament.

I've had limited success tuning my retraction settings, but I find that I need different settings for different extrusion speeds. For example, after an extrusion like G1 E20 F240 a 3mm retraction, 3mm extrusion, then a fast retraction creates a nice, clean break (this routine is recommended here by kraeger on the SeeMeCNC forums). However, after an extrusion like G1 E20 F900 I have to use longer  retractions to get a clean break.  I think this might have to do with the filament acting like a spring inside the bowden tube. It would make sense to me that the harder you push the filament, the more you need to pull back to compensate for the pent-up spring force.

Here's my question:  Is there a way to read the value of the extrusion speed, essentially the "F" term from the gcode commands, and change my retraction routine accordingly.

Example pseudocode:

If F value &lt; 500 Then do short retraction
If F value &gt; 500 AND F value &lt; 1000 Then do medium retraction
If F value &gt; 1000 Then do long retraction


I'm using the tool change script feature in Simplify3D to store the tool change code.
I don't think you're going to find either a firmware feature or a slicer feature that handles specifically what you want to do. The slicer would probably be the best place to put it, and I'd recommend maybe opening a feature request ticket with Ultimaker, because that sounds like an awesome feature.

That being said, there's nothing stopping you from post-processing your GCode file after it's been generated. If you're experienced with python at all, that's the place I'd recommend you start.

You'll probably want to do it via the following:


Find the first line number that does a retraction.
Sum up all the extrusion distances between that line and the starting point (the beginning of the file)
Replace the retraction distance and feedrate with whatever your short/medium/long retraction settings are
Store that line number as your new starting point
GOTO 1.


If you're using Slic3r, there's actually a post-processing script function built into the app itself, you just need to write the script and give it to the application to make the whole process hands-off. For other slicers you'll probably just have to run the script manually between slicing and printing.