How to break up the URScipt if the script is too long

I am working on developing an application that utilizes the UR5 robot and a welding machine to print 3D metal objects. My application relies on URCaps to translate Gcode 3D printing files to URscript, but I’ve encountered an issue where the robot cannot handle larger Gcode files. Although I can generate a few hundred lines of URScript, it’s not enough to handle the larger files. I’m wondering if there are any solutions to this problem?

Here is the video of the project.
First success multi layers weld UR5 robot - YouTube

As youve experienced, polyscope is not good at handling massive sequences like yours. For massive scripts like this, you might benefit from streaming the script commands to the robot through the primary or secondary interface. (as opposed to in polyscope gui)

When operating like this, the robot must be placed in remote mode and there will be no formal “program” running on the robot itself. The arm will be at the mercy of the script commands you send it.

The trade off is exactly that - polyscope gui is not tracking the program and it is more challenging to identify where in the program errors occur.