Weird problem with Loft command -

Hi, i’m running into a problem where I would like to
a) understand where the problem comes from
b) know what I can do to resolve the problem

So the idea of the construction was to create 4 adjacent square that will be move upwards a certain number of times and that will be rotated a certain amount around the respective square center on every move up in order to create a kind of twisted shape,
so you would get 4 squares on every moves that are rotated and intersect more or less, then i would create a union of the 4 squares in order to get a kind of cponvex hull of the 4 squares and then I wantes to loft the newly constructed curves:

This works also fairly well but I get some weird result on the loft where at some points kind of crazy movement of the loft - and I suspect it has something to do with the seam of the curves, but I don’t see whats wrong:
4xRot_square_test.gh (15.1 KB)

I attach some images and the SCRIPT ; will be grateful for any suggestion.

Here another way taht I tested it where the same problems happens
4xRot_square_test_2.gh (17.9 KB)

Hi Jules,

See quick-fix, attached:

4xRot_square_test_QuickFix.gh (33.5 KB)

The problem does seem to be with the seam (:grinning_face_with_smiling_eyes: ) after the RegionUnion, partly because it jumps location (at curve 50 on my machine) but also because of the very short curve segments that can result from your rotation parameters - remapping the seam to the ‘correct’ vertex at each level would be pretty tricky (especially for all geometries and rotation scenarios). I can think of a few methods but don’t have time to try them, so see if this quick fix will suit your needs.

Thanks @Jack_Brown ; this is perfect, i will try it the next days on my 3d clay printer;
I had found a workaround with shrinkwrap in order to avoid the weird vertex movements, but your solution is more relevant for similar objects that I will work on !
And this way I’ve also learned something !
Kudos for this

@Jack_Brown and here the result