Block reference - Extract how much block references there are in a layer

Hi Dynamo users,

I’m trying to extract how much block references are drawn per specific layer. So I’d just like to have a list with the name of the layer in column 1 and the number of block references in column 2, but I don’t know how to do it. Does anyone have already done it or knows how to?

Nicolas

Hi @nicolas.fernandez,

A List.GroupByKey node is probably best for this.

  1. Get the list of BlockReferences that you want
  2. Use Object.Layer to get the layer name of each BlockReference
  3. Use List.GroupByKey with the BlockReferences as the list and the layers as the keys

From there you could use List.Count to get the number of BlockReferences in each sublist.

1 Like

He @mzjensen ,

Thanks for your reply!
I’ve tried it, but it still doesn’t work… I would like to have different lists by their name, so that the counting would give 4 of a layer and 1 of the other. Here is a screenshot of my script, maybe you could see what to do.

I think you have the inputs swapped.

1 Like

It worked! Thanks!!