Group Curves by Sum Length - Electrical Wiring Approach

Hello,

I am trying to create an approach to help with electrical wiring.

BACKGROUND: I have created an assembly of connected units to fill a space. The units are a ‘random’ combination of the following lengths: 2’, 3’, 4’, 5’, and 6’
The assembly follows a LINEAR orientation. going from one ‘end’ to another.
There are a set of BASE curves that follow the linear orientation and could easily connect to form one polyline. There are also ADDED curves that are placed ‘randomly’ along positions that follow the path of the BASE curves

GOAL: Now that the curves are created, I need to group them based on how many power drops are required. For example, if the generated curves (assembly of units) exceeds a total unit length of 20 feet for the group, a second power drop is required. 1 power drop can power a total sum of 20 feet of unit length. SO, I need to group the curves in groups that have sum lengths of 20 feet or less.

THE CATCH: The curves in the groups need to be ‘adjacent’ to each other / they need to follow the flow of the LINEAR path. Currently, I am doing this based on X-> value of end points of all the curves and it is wanting to group curves that are not ‘adjacent’. ALSO, my current solution is splitting curves in segments instead of keeping them whole. Need to stay away from loops as well, uploading this def to ShapeDiver and ShapeDiver does not like loops…

Ex’s//
Current (Not Correct) Solution:

Should Be:


and this should be image was made on the fly, the groups may not be exactly that but trying to show that they follow the linear path and are ‘adjacent’ within their groups

Please help, very stuck, thanks

20’ Length Sum.gh (30.0 KB)

Hello Dominic,

I see this topic is related to this previous thread.

There seems to be a unit problem as the groups appear to get split correctly with a maximum length of 170 mm, not 20 something. Change that value to meet your requirement.

Anyway, here is a solution. This uses this thread’s idea implemented in a C# component. Prior to that the trick is to sort all these lines along the path - it’s much helpful that your input is correctly defined.

NetworkOfLinesByMaxLengthSum.gh (12.8 KB)

Yes, I attempted to adapt the definition you provided on the previous thread with no luck… As for the C# code, I was unable to get it working with anything I tried - had no idea where to even implement that code into my current definition. But that is what I needed. Now to see if it works within ShapeDiver!