with your help I solved the problem.
I am glad to hear that.
However I have not used functions "KGA_Sys_VarStackPush" and "KGA_Sys_VarStackPop".
Why did you have entered these functions?
To avoid highlighting and gripping the 'sssetfirst' selection set. You may not notice any effect on small sets (although in BricsCAD I do detect an extra 'blink') but even then this will have an impact on speed.
Instead of using your functions KGA ... I preferred to use (setvar "GRIPS" 0).
Unfortunately, the error appears:
the AutoCAD variable properly rejected: "GRIPS" 0;
This happens why it is inserted into a reactor?