I found this on a facebook group, it was a good idea but he had one for each axis and 100 lines in each one to move it back and forth for him.
I use this when I lube my Linear rails often but had been just typing it in the console as G1 X0 then G1 X240 and then I would hit the up arrow twice and enter about 2 dozen times to make my axis move back and forth.
Well now I can just run this macro and make it move for me!
[gcode_macro Axis_Break_In]
gcode:
; call with Axis_Break_In AXIS=?? FR= ?? MIN=?? MAX=?? TIMES=4 HOME=1
;home = 1 will make it home even if the printer thinks we are already homed
; if TIMES is excluded set the default number of moves below in the FOR I IN RANGE line
; I added a few variables so that you can use for any axis with any limit you desire, if you Z can travel 290 but X and Y only 235
; you can call it here MIN isn't requried if you omit it will use 0 since every printer can travel to 0 *one would hope!
; I also decided to make a default speed of 1500, feel free to edit
{% if 'AXIS' in params and 'MAX' in params %}
{% set Axis = params.AXIS %}
{% set FR = params.FR|default(1500)|int %}
{% set min = params.MIN|default(0)|int %}
{% set max = params.MAX|int %} ;set all variables needed
{% if printer.toolhead.homed_axes != "xyz" or params.HOME == "1" %} ;if all axis already home, skip the home
{% if Axis == "Z" %} ;on printers with a sensor XY must be homed first, so just do a full home
G28
{% else %}
G28 {Axis} ;home induvidual X or Y
{% endif %}
{% endif %}
{% for i in range(params.TIMES|default(2)|int) %} ;start the loop, default 2 times if not specified in params
G1 {Axis}{min} F{FR}
G1 {Axis}{max} F{FR}
{% endfor %}
{% endif %}```