Divide a duct to a length not greater than 3.92 ft

Hi Erfajo,
I am new to revit and dynamo and if I ask any stupid question please dont mind. I tried your DuctByLengthUnionConnected.dyn and it worked like a charm. We use 1400 lengths for duct and I changed your code slightly.

. When I run dynamo. it makes the first duct peace to be 1401 and the rest to 1400. The problem is when i re-run the code, it will try to break the first peace again as it is larger than 1400 and tries to put a joining peace. How do I change the code to make sure all elements are 1400 long.

Secondly, If i replace the first two nodes with a select model element node, it works great for the first pass and if i draw new ducts and try to re-run the code it. it will undo the first pass (joint the elements it split in the first run) and splits the elements selected. Can you please advice me what changes I have to make to fix it.

CheersDuctByLengthUnionConnectedSelectElement.dyn (33.2 KB)
DuctByLengthUnionConnected.dyn (33.5 KB)