Nonlinear extrusion only applies to print moves, as in, moves that have a combination of XY and E moves, and not standalone E moves. Is that perhaps why your macro didn't take it into account?