.. include:: .. include:: 3dprinting_substitutions.txt .. meta:: :description lang=en: Automating temperature towers and test prints using custom gcode for 3D printing with PrusaSlicer. .. _prusaslicer_other_gcode_mk3: Other custom G-Code for the Prusa i3 Mk3 ---------------------------------------- You can also embed custom g-code at before and after every layer change, on tool (nozzle) changes and between sequentially-printed objects. Automating temperature towers with g-code ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Here's an example of using before layer change G-code for changing temperatures on a temperature tower. This model consists of 10mm segments which are printed starting at 235C and decreasing by 5C at each 10mm layer. Note that ``layer_z`` is the |PS| placeholder for the current nozzle height in mm, *not the layer number*. .. literalinclude:: 3dprinting_prusaslicer_layer_change_g-code.txt :linenos: :language: none :caption: |PS| temperature test tower g-code When inserted into |PS| under **Printer Settings->Custom G-code->Before layer change G-code**, this code compares the current height to the height at which each segment begins (multiples of 10mm at the start of each layer. The first range matched will terminate the tests, so we start testing for the lowest tiers first (10mm) and working our way up to the highest (110mm), settings extruder temps along the way (``M104 Sxxx``). Automating linear advance test towers with g-code ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Here's another example of using before layer change G-code for inserting Linear Advance "K-value" settings on a test tower. This model consists of a 1mm high base with 10mm segments with stacked 10mm test segments. Each segment is printed with a K value that increments starting from -0.02 (``M900 K-0.02``) and increasing by 0.02 up to 0.30 (``M900 K0.30``). Note that ``layer_z`` is the |PS| placeholder for the current nozzle height in mm, *not layer number*. .. literalinclude:: 3dprinting_prusaslicer_layer_change_g-code_LA.txt :linenos: :language: none :caption: |PS| Linear Advance test tower g-code When inserted into |PS| under **Printer Settings->Custom G-code->Before layer change G-code**, this code compares the current height to the height at which each segment begins (multiples of 10mm at the start of each layer. The first range matched will terminate the tests, so we start testing for the lowest tiers first (10mm) and working our way up to the highest (110mm), settings linear advance along the way (``M900 Kxxx``). Changing print speeds at higher layers ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ It can be useful to reduce print speeds on taller prints. Inserting something as simple as: M220 S{if layer_z < 20}100{else}90{endif} ; M220 adjusts feed rates to 90% at 20mm height into |PS| under **Printer Settings->Custom G-Code->Before layer change g-code** can be done to automate this process. .. include:: 3dprinting_footer.rst Last edited on Jun 23, 2021. Last build on |today|.