Running custom G-code at a specific layer number and for a specific filament
 
Notifications
Clear all

Running custom G-code at a specific layer number and for a specific filament  

  RSS
jphalip
(@jphalip)
Eminent Member
Running custom G-code at a specific layer number and for a specific filament

Hi,

I'd like to run a G-Code macro in Klipper when the print reaches a specific layer number, and when a specific filament is used. For example, "If it's the 4th layer and the filament is PLA, then run this macro".

I figure this might be possible by tweaking the printer settings under Custom G-code > Before layer change, but I can't quite figure out how.

Do you have some tips?

Thanks in advance!

Julien

Posted : 10/05/2023 10:21 pm
Neophyl
(@neophyl)
Illustrious Member
RE: Running custom G-code at a specific layer number and for a specific filament

Just add the following.

{if layer_num == 3 && filament_type[0] == "PLA"} M117 INSERT ME {endif} ; This will insert the 'M117 INSERT ME' line on layer 4 if the filament type is PLA (configured as that in the filament settings. Layers are numbered from zero so the 4th layer is 3

into the custom before layer gcode filed under Printer Settings.  It will be up to you to tiee this into whatever Klipper setup you have.

Posted : 10/05/2023 11:10 pm
jphalip
(@jphalip)
Eminent Member
Topic starter answered:
RE: Running custom G-code at a specific layer number and for a specific filament

Perfect, thanks so much!

Also, the per-layer custom gcode feature is only available in printer settings and isn't supported in the filament settings yet, correct?

Posted : 11/05/2023 12:32 am
Neophyl
(@neophyl)
Illustrious Member
RE: Running custom G-code at a specific layer number and for a specific filament

Correct. What’s available in different areas is dependant on the version of Prusa Slicer you are running.  There is a table in the Prusa Slicer Knowledgebase that lists what is and isn’t in 2.5 and the 2.6 alphas.  

Posted : 11/05/2023 5:11 am
Neophyl
(@neophyl)
Illustrious Member
RE: Running custom G-code at a specific layer number and for a specific filament

Found the table I mentioned https://help.prusa3d.com/article/list-of-placeholders_205643   

Posted : 11/05/2023 6:44 am
Share: