# G-code wait for extrude command to finish

I have following G-code to prime the nozzle before start of the print.

G28 ; home all axes
G0 Z5 F5000 ; lift nozzle
G0 X30; move to X30
G28 Y; home Y
M420 S1; turn on bed leveling
M109 S220; wait for hotend temperature
G1 E20 F1800; extrude filament 20mm


The idea is to extrude a strand of filament outside of the bed and then start the print. The strand catches on the bed a tears off. So the ooze does not mess up the first layer.

The problem is that the G1 E20 F1800 does not wait for the move to finish and the controller goes to next move immediately. This means the nozzle is going to start the first layer, while spewing filament along the way.

Is there a way to wait for the move to finish?

I have tried M400 which seems not to help. I'm using Marlin Firmware.

• Try to add a small rise e.g. of Z to the last command. I use similar script printing "big dot" on the side, while going up at the same time. (And then prints the initial line with the seperate command.) This works well for me. Btw. Marlin docs says for G0-G1: "These commands yield control back to the command parser as soon as the move is queued, but they may delay the command parser while awaiting a slot in the queue." ...whatever it means. – octopus8 Apr 3 at 8:56
• Are you sure the move didn't finish? Attempting to extrude that much at that speed will not actually do so unless you have a really powerful hotend. Instead it'll build up the max pressure the extruder can give prior to slipping and continue to ooze for a long time after the move. This is not a workable way to prime. – R.. GitHub STOP HELPING ICE Apr 3 at 11:33
• @R..GitHubSTOPHELPINGICE I was about to write an answer in this line, please post an answer. Note the a retraction prior to move may help, alongside slower extrusion. Please post an answer! – 0scar Apr 3 at 21:57
• OK, will do that. – R.. GitHub STOP HELPING ICE Apr 3 at 22:50

Are you sure the move didn't finish? That would be very unusual, not the way 3D printer firmware normally operates. A new G0/G1 move command does not execute until the previous one finishes, whether it's extrude-only, travel-only, or a print move (mix of extrusion and travel).