Number Sequence, Nested Families

Hi All,

Still stumbling my way through Dynamo at the moment. Looking for a few suggestions on what would be the best node to improve the following situation.

Have written a graph to number piles from left to right. The issue occurs when the piles are nested into the pile cap. The pile cap is numbered at the end of the number sequence instead of with it. Ideally would want Dynamo to number all the piles in sequence, once a pile cap is found number piles within in a clockwise direction.

Open to suggestions from the group. Images of the graph and piling situation below

@Leopold, this could be easily done via the “Element positioning” tool from Revit Extensions. It provides different numbering sequences and patterns, so you don’t need to reinvent the bicycle.

Hi @zhukoven,

Not so much trying to reinvent the bicycle, more of a learning curve to improve it and build bigger and better things from it.

1 Like

It looks like your current method is not numbering them based on left to right - it’s numbering them based on element ID via the select all of family type and you just happened to place them in this order. To confirm this, delete the pile marked P001 and place a new one at the same point or slightly to the top left of the previous. Re-run the script and you’ll see it gets a value other than P001 - likely P019.

So we’re onto sorting. I personally like the “by curve” method for that type of issue - it allows revisions without much effort as the design updates.

https://dynamonodes.com/2016/01/24/select-elements-by-curve/

Alternatively you could automate this further by sorting based on locations as was asked, but you’ll remove the human element in doing so. Process would be something like this:

Get all piles and pile caps.
Get pile locations as points.
Find the pile caps boundary lines, convert that geometry to a polycurve and do a polycurve containment test on the pile points.
Filter out piles which return true (contained in the boundaries of the pile cap).
Add the pile cap to the list of piles, getting it’s location as either an average of the polycurve’s endpoints, or a maximum Y minimum X value of the points point (not sure which you’d prefer but I’d guess max Y minimum X).
Round the points Y values to the nearest i units where i is the degree of location tolerance - if one is 3" below the others axis I am doubtful you want it to be on the next line.
Group by the points’ Y values and then sort largest to smallest.
Sort the groups by the points’ X values from smallest to largest.
Replace the pile cap with the piles which were filtered out in the previous set.
Flatten the list and set that in after the all elements of type node, continuing as before.

This won’t do the clockwise request yet but once you get that setup you may have an idea as to how to best proceed from there.

1 Like

Thanks for taking the time to reply to this @jacob.small. I will look at implementing your suggestions.

Lee.