Cleaning the nozzle every Xth layer G-code I want to make a G-code script for Cura to clean the nozzle every Xth layer or every one minute?
With Cura there is only start and end G-code, so there is no &quot;layer change&quot; G-code like another slicer (e.g. Ideamaker).
Where should I write the code?
How can I define the Layer number?
There are extensions for Cura that can do almost what you want to do for you (with respect to the layer or height).
You need to add post-processing scripts to the Cura slicer. You do that from the top menu options Extensions -&gt; Post Processing -&gt; Modify G-Code and then add the option of choice.
E.g. for an event at every layer change you should use script &quot;Insert at layer change&quot; and fill out the G-code you want to perform.
There are options to write your own extension, but that would require some software development skills.
Optionally, you could use the &quot;ChangeAtZ&quot; script to add absurd temperature changes of the extruder to post process that later by a simple e.g. Python script (outside Cura) to replace those actions with the cleaning actions you want to perform. But, when you can do that, you could write a script outside Cura to detect the layers (e.g. from the comments or from the layer change command G1 Zxx) and insert that right away.
For inserting this on the basis of time would be very difficult, it is difficult to estimate the time printing actions take to then inject such a script.