Count Number of Occurrences of Assembly

Trying to get the count of the number of occurrences of an assembly. Within the assembly is a Structural Framing Family that has the parameter “Quantity” that I want to write to. The problem is that I got that information extracted but I cannot get it to point towards the right assemblies/Structural Framing Family that is counting . It will only populate the first (3) items on the list.

List.GroupByKey is grouping your names based on the names. When you finally write the value back to the assembly parameter you’re using the original list of elements. You should be grouping the elements based on names. This means you won’t need to create a dictionary because your elements will already be in the correct order. You can also use List.Count instead of counting strings and adding them together.

I believe I need to get the ElementID for the items listed in the Unique Keys List. I feel if I can pull that out it’ll get me my end result. I am not exactly sure how to accomplish this task?

SetParameterByName takes elements, like you’re currently supplying it, not IDs. The problem is that you grouped the values and modified them without doing the same grouping to the list of elements. The values no longer line up with the elements.

Yes, I can see what you just did and this makes sense to me.

We are so close! here’s where I am stuck. Not sure how to make a String into Elements and keep the group we just made. Not sure how to make a group into a var.

You’re still grouping the values (strings) instead of the elements.

Yes the Elements is what I need to group. I did find a way to do this but I have them currently in a list. The Elements are grouped with the “Assembly Name”, not everything is Assembled yet in the model as it would be the in a producing project.

I have added notes to the image so you can see what I am potentially trying to do. Thank you for your help so far.

Try this:

Thank you Nick, that was the ticket!