Jump to content
Ultimaker Community of 3D Printing Experts

Order of generated Gcode


Recommended Posts

Posted · Order of generated Gcode

When i generate the gcode ,Cura has several lines of code BEFORE my Start code


;Filament used: 4.23728m, 3.32624m, 3.69776m, 4.26778m
;Layer height: 0.28
;Generated with Cura_SteamEngine 4.12.0
M190 S60
M104 S215
M104 T1 S175
M104 T2 S175
M104 T3 S175
M109 S215
M109 T1 S175
M109 T2 S175
M109 T3 S175
M82 ;absolute extrusion mode
; ABOVE this line is generated by cura
M82 ;absolute extrusion mode
G28 ;Home
Z_TILT_ADJUST ;true bed level
BED_MESH_CALIBRATE  ;preform bed mesh
G92 E0
G1 F200 E3



My Issue is the "T0" placement before the heating section.

i have code to run after tool selection that errors because of heaters not on.


is there any way to move the "T0" after the Last "M109"?

 I am running a Octopi and klipper on a Octopus V1.1

cura ver.png

  • Link to post
    Share on other sites

    Posted · Order of generated Gcode

    I'll take a stab at this.  It would be good if you would go to Machine Settings and copy your StartUp Gcode and paste it into a response here.  Without it I have to guess (and that is never good).


    It looks like your StartUp Gcode is configured to heat T0 to print temperature while heating T1, T2, and T3 to the material standby temperature.  My guess is that T0 is going to print the skirt/brim/raft and so is the Initial Extruder.

    You could alter the StartUp Gcode to insure that all are at printing temperature if that is what is required.

    Right now you may have something like:

    M104 S{material_standby_temperature} T1

    if it was:

    M104 S{material_print_temperature_layer_0} T1 ;then it would heat to print temperature, but it would not wait.

    M109 S{material_print_temperature_layer_0} T1 ;would wait for it to get hot, but you would be waiting a while as each extruder would heat in turn.

    If your power supply can handle it then...

    M104 S{default_material_print_temperature} T0 ;Start to heat

    M104 S{default_material_print_temperature} T1 ;Start to heat

    M104 S{default_material_print_temperature} T2 ;Start to heat

    M104 S{default_material_print_temperature} T3 ;Start to heat

    M109 S{default_material_print_temperature} T0 ;Wait

    M109 S{default_material_print_temperature} T1 ;Wait

    M109 S{default_material_print_temperature} T2 ;Wait

    M109 S{default_material_print_temperature} T3 ;Wait

    would start to heat each hot end in turn, and then wait until each had reached printing temperature before continuing with the rest of the StartUp Gcode.

    You could enter additional M104 lines to allow the hot ends to cool to the standby temperature and finish with the extruder that will be used first;

    M104 S{material_standby_temperature} T0 ;Cool

    M104 S{material_standby_temperature} T1 ;Cool

    M104 S{material_standby_temperature} T2 ;Cool

    M104 S{material_standby_temperature} T3 ;Cool

    M109 S{material_print_temperature_layer_0} T{initial_extruder_nr} ;Heat the initial extruder

    Without knowing what you have now I can't be sure but I think the above is in the ballpark.  Wherever you end up, it won't be really simple.


  • Link to post
    Share on other sites

    • 2 weeks later...
    Posted · Order of generated Gcode

    below is my startup code

    ; ABOVE this line is generated by cura
    G90 ;absolute positioning
    M82 ;absolute extrusion mode
    G28 ;Home
    Z_TILT_ADJUST ;true bed level
    BED_MESH_CALIBRATE  ;preform bed mesh
    G92 E0


  • Link to post
    Share on other sites

    Posted · Order of generated Gcode

    If Cura doesn't see any temperatures in the StartUp G-Code (and you currently don't have any) then it will add temperatures before the StartUp GCode to insure there is no Cold Extrusion.  I'm not sure how it picked T0 to heat first.  It may be the Initial Extruder (or Cura simply defaulted to T0).  Since it picked T0 to be first then the other three extruders are only brought up to Standby Temperature for the material each has loaded.

    Although T0 does heat first the M109 S215 line insures it is up to printing temperature prior to the StartUp Gcode being executed.  The other three are not...they are brought up to Standby Temperature.


    Which extruder do you need active for"...I have code to run after tool selection."?  Do you need each extruder in turn up to print temperature?  Are there prints you run with (for example) T1 and T3 active but with T0 and T2 disabled?  (That combination would be tricky.)

    Is the "...Code-After-Tool-Selection":  Within the gcode file or are you calling a separate sub-file with M32 or something similar?


    You could post a gcode file that you like and that contains the Code after Tool Selection.  You might have to hand code parts of it.

    Without knowing exactly what you want to happen (and when) I'm shooting in the dark.



  • Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

    • Our picks

      • Ultimaker showcase | April 2022 | 4pm CEST | 10am EDT
        I'm excited because I've personally produced this showcase event, so if you are curious what else I'm up to nowadays, come check it out and say hi in the chat! It would mean a lot! 
          • Thanks
          • Like
        • 4 replies
      • New here? Get ahead with a free onboarding course
        Often getting started is the most difficult part of any process. A good start sets you up for success and saves you time and energy that could be spent elsewhere. That is why we have a onboarding course ready for
        Ultimaker S5 Pro Bundle, Ultimaker S5, Ultimaker S3 Ultimaker 2+ Connect.   
        They're ready for you on the Ultimaker Academy platform. All you need to do to gain access is to register your product to gain free access. 
        Ready? Register your product here in just 60 seconds.
          • Like
        • 11 replies
    • Create New...