You GUI in the EJS is so complicated that I do not really understand it.
I saw the whole system is expanding when I run it.
I do not know what is going on.

You should re-assign those property value if it's background is not white.

You did not provide detail information about your system, size/shape ...
The GUI you have is not the same as the one I have created.
I do not know how it should look like. There is no way I can help if I do not know what it should be look like.

You do not need to add a new tube element for each segment,
if you define
in variable tabs.

and assign px to Pos X and py to Pos Y for tube element, you will create two connected tube.
You can add more if you define px,py with more dimensions .

Why there are so many arrows in the GUI, you should be able to use a polygon to draw all connected segments.