Error in script and updated

<a class=“attachment” href=“https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/4/0/409d4976ccaf2831c6f89391Script ArrangeTiles.pdf (158.7 KB)
script arrange tiles.3dm (325.7 KB)
6cd794a52abe0524.rvb”>ArrangeTiles.rvb (11.1 KB)

Hello
I need support in 3 points.
1º I run the script Arranje Tiles with the file script arrange tiles.3dm and I get one error can be check in attach file Script Arrange Tiles.pdf.

2º I need the script updated in two points.
a) Conected all elements with one line.
b) Cut the elements in the conection line.
Thank you