I apologize @BIGAL, because I don't think I explained myself well. The code was generated entirely by COPILOT, Microsoft's AI, following the instructions I gave it.
If there had been a previous author in this case, I would have mentioned it, just as I've confessed that I'm a huge fan of @Lee Mac's work.
And I don't think I made it clear that if any member of this group, expert or not, feels like improving this code, I'll be very grateful, as it's code that could be very useful in my profession.
I'll try to add the necessary code to account for the UCS rotation (Array if a new UCS OB).
Replying to @SLW210, I think the simplicity of the code lies in the fact that it can use NFPA values as well as FM Global or UNE EN 12845 values, since it only requires adding distances.