Save selection set by element?

Hello, is this Clockwork node broken in 1.2 ?

Thank you

Hi @Giovanni_Succi,

Can you open the Custom node and copy the contents to the master graph, plug it in and see what warnings you are getting? The warnings are hidden while wrapped in the custom node and it’s impossible to see what’s wrong with your current image.


Hi Giovanni

I found got a simalr result in one of my scripts. The reason for the null is in my case that the model include filters with name including special signes like æøå (Danish letters) After a bit of renaming to the filters the node “SelectionSet.BeElements” works well.

I’ve got same problem. Has Anyone found a solution?

I can’t replicate this error. Can you please upload the graph you are using and also a sample revit file that you are getting errors with so we can have some more context.

Yes of course. Here it is:

I stuck in this place without idea why You can use this node without any problem. Thanks in advance for any suggestion.

Hi @PiotrS,

Apologies for the delay, I didn’t get a chance to look at this over the weekend.

I tested your script and model, in 2020 it works fine. However, in 2018 it does not. I traced this back from the error to one line of code which was…

if str(filter.Name) == name:

That I replaced with…

if filter.Name == name:

Here is the full code which you can copy into the node…

import clr
from Autodesk.Revit.DB import *
from System.Collections.Generic import *

import Revit

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'

import traceback

doc = DocumentManager.Instance.CurrentDBDocument
name = IN[1]

# create itemset
items = UnwrapElement(IN[0])
ids = list()
for item in items:
itemset = List[ElementId](ids)

	# collect all existing filters from the model 
	names = list()
	collector = FilteredElementCollector(doc)
	filters = collector.OfClass(FilterElement).ToElements();
	selset = False
	# if a filter of that name already exists, delete its content
	for filter in filters:
		if filter.Name == name:
			selset = filter
	# create a new selection set if it doesn't already exist
	if selset == False:
		selset = SelectionFilterElement.Create(doc,name)

	OUT = selset.ToDSType(False)
except Exception, ex:	
	OUT = traceback.format_exc()

I’m not sure why this is an issue, I will dig into it more.



Ok, had a quick look at the why. It turns out that the Filter.Name is in Unicode. For some reason, when converting this to string in Revit 2018, the encoding fails with this error. However, in 2020 this is not an issue. The python I supplied above seems to work in both cases, regardless or the language I am using. If it fails, let me know.



Hi Daniel,
It works :wink: Thank You very much! I attached my script which is connected with “rythm” node. Useful when You need to get all elements with the same value of choosen parameter.

Selection set_v.2.1.dyn (19.5 KB)

1 Like

Nice one @PiotrS! Glad you have it all up and running nicely now!

Hello again,
Could You tell me, is it possible to get the selection set (and all elements within it) by its name?

I’m still trying to find a solution. I’ve tried 3 different nodes, but without success.
Maybe someone knows how to do it with CodeBlock?

Ok, if someone needs a solution, here it is:

Inputs: Value and Filther Method: