Yes, provided the workpiece was always at the same position.
I have just today been using AI to make a visual ‘Macro Builder’ that allows you to create gcode for your machine and visualise the result. I will update this thread this afternoon when I have something published.
EDIT: Made a post here about the macro tool and also another tool I vibe coded.