Only select elements with the same name

Hello everyone! I tried searching for this in the forum, but not sure I am wording it correctly, so apologies in advance if this has been previously addressed.

I have a script that requires the user to select elements in the active view. All of the elements are of the same category, but are named differently. Once the user selects the first element, how can I control the selection from that point forward to where the user can only select elements with the same name as the first selected element?


@staylor ,

there are a lot of variations. I am not sure if your “selection” methode should be the aim… … you can use f.e. GroupByKey

or even (outside of dynamo) using a schedule to find elements with the same name…

or to follow your way… maybe like this:


1 Like

thanks @Draxl_Andreas , In this case I want to control what the user can and cannot select in the view. I don’t want the user to be able to randomly select different elements and then have the graph filter everything out that doesn’t meet the criteria of the first selected element. This would be very similar to the Isolated Pick Model Elements node, where you input the category and only elements of that category can be selected. I just want to push it to a lower level and isolate the selection by the element name. Hopefully this clarifies a little more of what I am hoping to accomplish.

I have come across this function with an addin, so I have to assume it is possible within the Revit API.

You would have to do this in two parts. First, an unfiltered element selection by the user. This also defines the name or whatever property you want to filter by for the rest of the selections. Use that to create a filter and then start a new filtered object selection for the rest of the elements.


Thanks for the direction @Nick_Boyts

I don’t know enough about python and the Revit API to create the filtered object selection from scratch, but I was able to take the code from the Isolated Pick Model Elements node and modify it for exactly what I need. Shout out to John Pierson and Dimitar Venkov for doing the work!!

The only quirk is that the Isolate Selection node does not see the first picked item, so it allows for that item to be selected twice. No biggie as I prune it out if it is picked twice. It would be nice if the first selected item could be appended to the list in the Isolate Selection node, so that it already sees that it’s been selected and can’t be selected twice. Any guidance on how to do this would be appreciated. Otherwise, the list UniqueItems handles it.

Isolate Selecting Elements.dyn (42.4 KB)

1 Like