Feature Request - Filament Runout Trigger 'PAUSE' After 700mm extruded (distance_delay?)

I was looking for the same thing to no avail so I had a crack at making it work with the existing macro functionality.

Usage: PAUSE_AFTER_D D={distance_in_mm}

PAUSE_AFTER_D gets the current extruded distance, adds the D parameter to it, then triggers a delayed_gcode that checks every second if the extruded distance has reached the endpoint yet.

I’ve only tested this so far as it pauses after D more mm have been extruded, resumes correctly and then will pause in the same manner after resuming.

Let me know how you go!

[gcode_macro PAUSE_AFTER_D]
description: Trigger to pause the print after a further 'd' mm has been extruded
variable_end_d: 0 #create variable "END_D" which is associated with the PAUSE_AFTER_D gcode macro
gcode:
  {% set d_start = printer.print_stats.filament_used|float %} #starting point is whatever the filament used is when PAUSE_AFTER_D is called
  {% set d_end = (d_start + params.D|float)|float %} #end point is start + D parameter
  SET_GCODE_VARIABLE MACRO=PAUSE_AFTER_D VARIABLE=end_d VALUE={d_end} #write the end value to the END_D gcode variable to access later
  M117 Pause at {printer["gcode_macro PAUSE_AFTER_D"].end_d|round(2)}
  UPDATE_DELAYED_GCODE ID=PAUSE_AT_D DURATION=1 #trigger the delayed gcode below after 1 second

[delayed_gcode PAUSE_AT_D]
initial_duration: 0 #if initial_duration is zero, the delayed gcode won't start by default
gcode:
  {% set d_current = printer.print_stats.filament_used|float %} #get the current filament used
  {% if d_current < printer["gcode_macro PAUSE_AFTER_D"].end_d %} #if we aren't at the stopping point
    M117 Stopping {d_current|round(2)} {printer["gcode_macro PAUSE_AFTER_D"].end_d|round(2)}
    UPDATE_DELAYED_GCODE ID=PAUSE_AT_D DURATION=1 #restart the timer on the delayed gcode
  {% else %}
    PAUSE
    UPDATE_DELAYED_GCODE ID=PAUSE_AT_D DURATION=0 #set the delayed gcode duration back to zero so it doesn't keep triggering
  {% endif %}