While Loop for Storm Structure Naming

I am trying create a graph that does the following:

Given a set of structures tagged as outlet locations, loop through all connected parts via Structure.Connections & Pipe.StartStructure to create a nested list with the following structure:

L1 - Outlet Structures
L2 - Structures within the same run as the outlet structure

I tried using List.Map, which worked okay to get just the furthest upstream structure within a given storm run, but it stops when it reaches a structure with more than one inlet connection.

Since L2 will not be a uniform length, and there could be dozens of structures along a given run, I cannot think of a way to achieve this without a while loop or a custom node (far beyond my abilities), but every while loop I’ve tried to build just returns an error.

You almost never need a loop, while or for, in Dynamo. Lacing and list levels will almost always help solve a given issue.

That said (and many others here) can’t help without a dataset showing what condition you have. Two outlets with a network connected to each should work - they don’t need to be real just something which mirrors your drawing structure.

1 Like

Unable to attach but here’s a sample CAD file and a Dynamo graph with a basic filtering for the inputs.
Greatly appreciate your help!

Was this in Civil 3D 2023, 2024, 2025, or 2026?

Got it open in 2025, figuring that is the median version by support lifecycle these days so it shoudl get most users to a workable solution.

Ideally these would have been modeled as separate networks, since they don’t touch and there isn’t any overlap. Assuming the goal is to split them into two networks in the end, I wrote a sample which should identify which pipes and structures belong to which outlet by way of the shortest path calculation between all outlets and each structure, and getting the first non-null result, and then putting a rectangle around the resulting geometry. So long as your networks are never connected, this should serve as a way to divide it.

The result:


This did manage to find a disconnected null structure which I’m guessing was a deletion or drafting error (see the small pink dot which is actually another rectangle between top of the red and green ones rectangles?).

And the graph:


Group structures by outlet.dyn (42.9 KB)

2 Likes

Oh my goodness! Thank you so much!

1 Like

Happy to help!

I recommend you study both the logic in terms of why, and the mechanisms used in terms of how, as the graph is a very good example of both.

2 Likes