Conditional GCode



  • Can conditional statements be included in gcode as they can in Marlin ?

    for instance this is run at the end of a print on my Prusa to move the extruder / hot end up and away from the last line printed - but it takes account of where on the Z axis the print completes and if less than max print height moves to either Z+30 or max print height.

    {if layer_z < max_print_height}G1 Z{z_offset+min(layer_z+30, max_print_height)}{endif} ; Move print head up

    I ask since search produces nothing definitive for RepRap other than it was being developed.



  • Not yet. Coming in a release of V3. From a few things the primary developer, @DC42, has said, coming relatively soon (next few months??)



  • As pointed out, comming "soon". Maybe follow this thread? https://forum.duet3d.com/topic/13516/conditional-gcode-and-object-model-variables/25



  • Followed .... hadn't found that one.



  • @Garfield said in Conditional GCode:

    Can conditional statements be included in gcode as they can in Marlin ?

    for instance this is run at the end of a print on my Prusa to move the extruder / hot end up and away from the last line printed - but it takes account of where on the Z axis the print completes and if less than max print height moves to either Z+30 or max print height.

    {if layer_z < max_print_height}G1 Z{z_offset+min(layer_z+30, max_print_height)}{endif} ; Move print head up

    I ask since search produces nothing definitive for RepRap other than it was being developed.

    Isn't this conditional slicing in Slic3r rather than actual conditional g code? The expression is evaluated at slice time and fixed G codes placed in the .gcode file. I may be wrong but the final gcode file is just standard gcode.
    If that's true it will work regardless of what firmware you are using.



  • @tekkydave yep that's all done in slic3r at slice time , nothing in the firmware



  • You know I've not looked, you're probably correct as I've just looked at some gcode produced by it and theres no conditions present, hadn't really considered the slicer's part in all this.

    So I guess the question becomes can the 'Printer' automatically add stuff based on specific conditions such as change tool, finish print, start print - so that slicers without the capability are accomodated ?


  • administrators

    @Garfield said in Conditional GCode:

    So I guess the question becomes can the 'Printer' automatically add stuff based on specific conditions such as change tool, finish print, start print - so that slicers without the capability are accomodated ?

    There are already specific macro files that RRF calls in those 3 situations.



  • I'm not sure what those are (will go look) but could we make it call specific / tailored macros to avoid messing with 'defaults' ?

    I apologise to all for whom this is old ground ... it's new to me I'm afraid.




Log in to reply