generate_autofit_macro function

Generate a macro file for autofitting