Tag piles in correct order automatically?

Hello guys!

I have an extremely tedious task that I would love to be automated for me with Dynamo. If possible of course. I need to tag 349 piles with different tags in the correct order. I would like it to go P101, P102, P103, 104 etc all the way to P349. They only way I know how to do that is by typing it manually 349 times. Is there a faster way to do it with Dynamo?

Here is an example of how the end result should look like

Is it possible to automate the Tags like this with Dynamo so that I don’t have to do it manually for every single pile?

I would be forever grateful if someone could help me find a solution to this!


Assuming that the starting point is a model full of piles with unfilled naming parameters, the flow of the graph would look something like:

  1. Collect all piles and produce a list of piles.
  2. Establish a numbering convention and produce a list of numbers (P101 thru P349).
  3. Use SetParameterByName to assign the correct parameter for your list of piles, the list of numbers.
  4. Take the appropriate view and the list of piles, and generate Annotation Tags (via Revit or via Dynamo). You will likely need to manually re-locate the tags for visual fidelity unless you get very complex with your placement method.

#2 depends entirely on your inhouse numbering conventions and aesthetic (what portion of the view gets the lowest numbers vs the highest numbers).

Example below. In this case I’m not particularly choosy about what is numbered where, but it shows general concept.


That helps a lot! :smiley: But what if I wanted to have a specific starting point for P101 and a specific point where it breaks and continues the counting on the row beneath the first row.


P1 P2 P3 P4 P5
P6 P7 P8 P9 P10

That gets into some fun position-based logic that can be found in other threads on the forum in much better detail than I can manage.

Something that might work:

  1. Get the element.location of each pile.
  2. Create a polycurve that follows the pattern you’re trying to follow (in this case draw topleft to topright, then run down to a new ‘row’, repeat as needed until plan is covered)
  3. For each pile location, find the point on the curve that represents the shortest distance to the curve.
  4. Convert the points on the curve to the curve parameter (0 to 1)
  5. Use this list of numbers from 0 to 1 as a sorting method for your original list.

Not a perfect solution as you’re describing what is closer to a typewriter style of ordering but it may get you started.

Another option would be to create Y-axis bins (0-10, 11-20, 21-30 length units,etc.) representing what a ‘row’ of labels should cover, bin your Y-data, then sort each bin by X-data.

That sounds amazing but the script that you sent earlier works pretty well actually! :smiley:
I can imagine a problem occuring though. For example, what if I use that script and get the numbering in the perfect order like:

P1 P2 P3 P4 P5 P6
P7 P8 P9

What if I in the future need to put a new pile between P4 and P5? Then I would manually have to rename every other pile; P5 would become P6 instead, P6 would be P7, P8 would be P9 etc. With other words, every pile would get a new number that would be “Their current number+1”.

I guess that Dynamo can solve that as well?

Option 1: Revisions are done manually and off-pattern (P4.1 for instance). This approach might be taken if the work is done ‘late’ in the design and there is some sort of history/design conversation that requires maintaining the old labelling.

Option2: Re-run the script. SetParameterByValue will overwrite the parameter with the new value regardless of whether it previously had a value or not. Since your annotation tags reference the parameter, the old tags would not require updates and you would only need to tag the new piles.