Hello, is this Clockwork node broken in 1.2 ?
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.
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 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.
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 clr.AddReference('RevitAPI') from Autodesk.Revit.DB import * from System.Collections.Generic import * clr.AddReference("RevitNodes") import Revit clr.ImportExtensions(Revit.Elements) clr.AddReference("RevitServices") 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' sys.path.append(pyt_path) import traceback doc = DocumentManager.Instance.CurrentDBDocument name = IN # create itemset items = UnwrapElement(IN) ids = list() for item in items: ids.append(item.Id) itemset = List[ElementId](ids) try: # collect all existing filters from the model names = list() collector = FilteredElementCollector(doc) filters = collector.OfClass(FilterElement).ToElements(); selset = False TransactionManager.Instance.EnsureInTransaction(doc) # if a filter of that name already exists, delete its content for filter in filters: if filter.Name == name: filter.Clear() selset = filter # create a new selection set if it doesn't already exist if selset == False: selset = SelectionFilterElement.Create(doc,name) selset.AddSet(itemset) OUT = selset.ToDSType(False) TransactionManager.Instance.TransactionTaskDone() 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.
It works 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.
Nice one @PiotrS! Glad you have it all up and running nicely now!