Quick update, we found another workaround that is actually simpler @chuongmep @DanielHurtubise @McLean @Shafeekh .
Disable GenerativeDesignForRevit
by moving it outside from the folder C:\Program Files\Autodesk\Revit 2023\AddIns
; Your code blocks will start working again
We’ll hopefully find a better solution soon