Macro evaluation help

I have a start_print macro that is causing a move out of range error when executed in the beginning of a print but not when it’s executed on it’s own. I also preheated the printer manually, ran the macro, and then started the print with the macro commented out. that worked fine.

here is the macro:

[gcode_macro start_print]
gcode: 
    conf_runout
    SAVE_GCODE_STATE NAME=start_print_state
    {% set initialExtruder = printer.toolhead.extruder %}
    G28 ; home all axes
    G90
    {% if printer.extruder.target >= 170 %}
        T0
        G1 X15 Y145 Z0.2 F15000 ; move to prime
        M83
        G92 E0 ; reset extrusion distance
        G1 X110 E15 F1000 ; prime nozzle
        G1 X200 F300000 ; quick wipe
        G92 E0 ; reset extrusion distance
        PARK_extruder
    {% endif %}
    {% if printer.extruder1.target >= 170 %}
        T1
        G1 X15 Y146 Z0.2 F15000 ; move to prime
        M83
        G92 E0 ; reset extrusion distance
        G1 X110 E15 F1000 ; prime nozzle
        G1 X200 F300000 ; quick wipe
        G92 E0 ; reset extrusion distance
        PARK_extruder1
    {% endif %}
    {% if initialExtruder == "extruder1" %}
        T1
    {% else %}
        T0
    {% endif %}
    RESTORE_GCODE_STATE NAME=start_print_state
description: Home and Prime

here is the gcode I’m trying to print:

here is my klippy.log:

here is the error message I’m getting (and the surrounding terminal echos for reference):


// shaper_type_x:ei shaper_type_y:mzv shaper_freq_x:48.200 shaper_freq_y:32.200 damping_ratio_x:0.100000 damping_ratio_y:0.100000
21:22:07 
// Activating extruder extruder1
21:22:07 
// shaper_type_x:mzv shaper_type_y:mzv shaper_freq_x:55.600 shaper_freq_y:31.000 damping_ratio_x:0.100000 damping_ratio_y:0.100000
21:22:07 
!! Move out of range: 10.000 146.000 0.200 [29.996]
21:22:07 
!! Move out of range: 10.000 146.000 0.200 [29.996]

can someone tell me how to get this to work the way I want it to?

new users can only put 2 links in their post…

here is the rest of my config if you need it:

With all the macros, it’s hard to say which move isn’t valid. You can add a bunch of GET_POSITION calls in your macros and also add {action_respond_info("some macro name")} to the top of each macro call as well. That might help track down which move went awry.

-Kevin

ok, I was trying to do that but I was getting confused because of how the macros are evaluated

so if one macro calls another macro that calls another macro, what happens?

[macro1]
thing1
macro2
thing2

[macro2]
thing3
macro3
thing4

[macro4]
thing5