Trouble with Script

Ok I am having an issue with a Dynamo Script I am trying to create. It is for Fabrication MEP Valves. I am trying to get it to Auto number the valves based on Service and Level. Unfortunately I can not upload the script for help so I am not really sure how to get help on this.

I have it set to search for all Valves based on the Service Type because it is classified as MEP Fabrication Pipework and the only way to distinguish it is a Valve is by that. Then I have it look for the Fabrication Service and then look at the reference level. I can make it auto number the valves just fine but what I can not make it do is start back at 1 on a new level.

Level 1 Valves should start at 1-001
Level 2 Valves should start at 2-001

I have it where it starts at Level 1, 1-001 and say there are 20 valves it ends at 1-020 and then on Level 2 it starts at 2-021 where i need it to start at 2-001.

Hope this can be followed, it seems tough without being able to upload the script.

I bumped your trust level so you should be able to post screenshots and files now.

You need to group your valves by level and get their respective counts so you can have unique ranges for each list of valves by level.


Tried that but still having an issue. If i group them by level first then the script does not work. I know I am close but I am also new to Dynamo.
ValveTesting.dyn (83.4 KB)

Can you post a screenshot? It’s much easier to troubleshoot. Just make sure you have the node preview bubbles pinned so we can see what’s going on.



A singular screenshot using Export As Image (located in the top right of your Dynamo window) would be easier to read, but it looks like you deal with the service type and the level separately. This is throwing everything off because you group your elements by service type but leave the levels in their original order. Try grouping the parts first and then getting the level from the grouped list. That will keep everything aligned.

I believe this is capturing the Level of the grouped parts, is it not? Thank you for the tip on Exporting as image.

Ok great. Then I think you want to group by Level first since that’s how you want the parts to be sequenced.

In your initial post you mentioned that you want the valves numbered by Service and Level but your example only shows them numbered by Level. Where does Service come into play? The idea is that you group by the primary parameter and then the secondary (within the primary group) to give you two sequences.

So the three steps to get what i need is:

  1. find Fabrication Valves with is designated by the Parameter value “53”
  2. find the Fabrication Service that valve is on
  3. Find the Level for the valves on each service

I am not sure the sequence that these three things needs to happen in but with testing if I look for the Valve (53) first, then the Service, then the Level it seems to work without errors.

My first attempt I put the Level before the Service and it broke most of the nodes.

I have tried rearranging the Cluster of Nodes and connecting them in alternate ways and the end result has always been the same.
Because Fabrication Valves are considered Fabrication Pipework and are not under a sub-category I thought I would have to find the Valves first.

The Goal of the Script is to number valves that are on the same service in sequential order 1-001,1-002,1-003 per service, per floor. The only number I need to change is the first number, if it is on the second floor then it needs to start back at the beginning 2-001,2-002,2-003 and so on.

I can find the valves, I can find the Levels, I can also find the service, I can get them to number but they number the same service as 1-001,1-002,1-003, 2-004, 2-005, I am not sure how to get it to restart the process for each floor.

Hope this makes sence.

This would mean you could have valves with duplicate Ids right? Since no part of the sequence is determined by the service, any first valve starting on level 1 would be numbered 1-001. I just want to make sure I’m understanding correctly.

If that’s the case then you’re really close. You just need to group the valves a second time - once by service and once by level. The important part here is that you maintain the list structure.

Something like this:

I tried the nodes you showed and i came out with this.
I only want the Valves so I need to find them all first.


It works except for the “Level(Name=Level 2, Elevation=11.5)”, just need that to say the level number “2”

I was just showing you an example of how the base logic should look. You of course need to modify the specifics to meet your requirements. Instead of using the full name of the level, that’s where you’d use your dictionary to get the number only and add that to the count.

Thank you so much for your help and pointing me in the right direction. Took a little bit to get to the end goal but here is what I got. It could probably be streamlined a bit more. Now I understand a bit more about Dynamo and what it can do and where to connect nodes.

1 Like

Awesome! That’s the goal. Now just be sure to mark the solution so others can use this thread as an example.