Run dynamo script by level

Hey all,

I currently have a dynamo script that will calculate the total reinforcement on a level and divide it by the total floor volume to give a reinforcement rate which works great so far. However, the only way to get it to work is by selecting the desired level in the level node and I’m hoping to have this run on every level in the project.

Currently it filters the list of reinforcement and floors by the input level. I’ve thought if I can group the lists by level rather than filter I should be able to get the output I need but I’m having difficulties with this. If anyone could help or give a me a nudge in the right direction it would be much appreciated.

Cheers, Jimmy.

To clarify what I mean by grouping. I thought to have a list with multiple lists i.e. the first list containing all the elements at level 1, the 2nd at level 2 etc. then I can get item at index. Or is this not the right way to go about it?

Thanks.

Here’s how you can get a nested list of model elements per level.

AllElementsAtAllLevels

@Jimmy - Certainly the right way.

You can then Map your script so that it applies to each sub list.

or

Define a function using your script and apply it to your list (of sub lists)

Thanks guys. Do you know how I would filter this list just to get all the floors? I would’ve thought using the element is of category node should work but it’s returning null.

filter by floor

 

 

Also the reinforcement is a detail item so I can not use the all elements at level node. Currently I am filtering by a text parameter which has the same name as the level. So I pick the level from the level node then use the string from object node to filter.

Cheers.

If you only want floors, you should just get all floors and group them by level:

FloorByLevel1

Thanks Andreas, I feel a little silly now. I was sure I’d tried that.

I’m trying something similar with the detail items, although a little rough at the moment but it’s also returning null. Saying that the keyProjector can not be a revit parameter. Is there another way around this?

detail item groupbykey

Yeah, I’m afraid that’s not going to work like that. The key projector needs to be a node that directly accesses a property of each element in your list. It works very much like the List.Map node in that one of the inputs of the node that acts as the key projector needs to be left unconnected (like the Element.Level node in the graph I posted above). It looks like you want to group items by parameter value which would work like this:

GroupByParameterValue

Thanks Andreas! You’re a legend! So elegant and so simple. Much appreciated. I’ve still got a bit to do but I have all the data I need now. Cheers.