Problem thicken wireframe

Hi all!

Again I am stuck and I don’t know why my script doesn’t work…
I made a script for a voronoi in the shape of a snake. On some surfaces it works, on other it fails (the loft command in the section ‘give thickness’) and I would like to understand what makes it fail.
I replaced the initial ‘surface’ command by a ‘brep’ because in this example I have a polysurface.

If I know why it fails or how to solve it I can change my shape in a more complex thing.

Thanks in advance! (19.9 KB)
forum.3dm (1.2 MB)