First layer extrusion multiplier Gcode question
 
Notifications
Clear all

First layer extrusion multiplier Gcode question  

  RSS
TeamD3dp
(@teamd3dp)
Reputable Member
First layer extrusion multiplier Gcode question

Going back to the pre-conversion MK4, I occasional had trouble with PETG goobers building up on the nozzle during the first layer of large prints.  At some point, I found (on this forum) some "Before Layer Change G-code" to reduce the extrusion multiplier for only the first layer.  I've done a number of large PETG prints since then and by using that Gcode to drop the first layer to 96%, the problem seems to be solved.  I'd like to use the same preset for all of my printing, and don't like the idea of needlessly under-extruding the first layers when using materials that don't require the reduction. 

I don't have a coding background (G or otherwise), so please forgive my ignorance here.  I'd like to add a material qualifier to only run this for PETG.  Borrowing a piece from another "if" statement I use in my start Gcode to skip absorbing heat, I'd like to know if the following syntax will work in the "Before Layer Change G-code" section to accomplish this.

;BEFORE_LAYER_CHANGE
G92 E0.0

{if layer_num <= 0 and filament_type[initial_tool] ~ /.*(PETG).*/}
M221 S096 ; first layer ext 96%

{elsif layer_num >= 1}
M221 S100

{endif} ;

 

This came up this morning because my son asked for help setting up PrusaSlicer on his laptop.  I decided to review the custom gcode before sharing it with him.  At one point this had been on my to-do list, but had fallen off of my radar.  Thank you so much for any help you can provide.

-J

Posted : 01/01/2026 4:33 pm
k1mu
 k1mu
(@k1mu)
Estimable Member
RE: First layer extrusion multiplier Gcode question

You're missing an "=" before the "~" in that.
I'd simplify this:

M221 S{if layer_num <= 0 and filament_type[initial_tool] =~ /.*(PETG).*/}096{else}100{endif}
Posted : 01/01/2026 7:28 pm
TeamD3dp
(@teamd3dp)
Reputable Member
Topic starter answered:
RE: First layer extrusion multiplier Gcode question

 

Posted by: @k1mu

You're missing an "=" before the "~" in that.
I'd simplify this:

M221 S{if layer_num <= 0 and filament_type[initial_tool] =~ /.*(PETG).*/}096{else}100{endif}

Thank you.  I'll use this instead. 👍

-J

Posted : 01/01/2026 8:07 pm
Share: