It wasn't 1-1 with clicks, and it took a ton of trial and error, but I managed to get there eventually with a project. Here's the passable write up I made for it, theres a link to the final script towards the end, hopefully theres enough to be helpful.
https://www.odinseye.cloud/musings/qgis_scripting/