I’ve been getting a weird error where the selection filters aren’t being implemented for the pickobjects method. Can anyone advise / replicate / confirm? CPython3
Node Name: Python Script
Package: Core.Scripting
Dynamo Version: 2.16.1.2727
Host: Dynamo Revit
Messages: TypeError : object does not implement ISelectionFilter [’ File “”, line 34, in \n’]
State: Warning
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
from Autodesk.Revit.UI.Selection import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
class Single_Category(ISelectionFilter):
def __init__(self, category_name):
self.category_name = category_name
def AllowElement(self, e):
if e.Category.Name == self.category_name:
return True
else:
return False
def AllowReference(self, ref, point):
return True
msg = 'Select Multiple Gridlines.\n\nPress Finish to complete.'
TaskDialog.Show("User Input Required", msg)
selection = uidoc.Selection
category_filter = Single_Category("Grids")
elements = selection.PickObjects(ObjectType.Element, category_filter)
if elements:
gridlines = [doc.GetElement(x.ElementId) for x in elements]
else:
gridlines = []
OUT = gridlines
These types of filters work fine in 2021 and 2022.
Could have something to do with this, namespace and object issues?
Node Name: Python Script
Package: Core.Scripting
Dynamo Version: 2.16.1.2727
Host: Dynamo Revit
Messages: AttributeError : type object ‘Selection’ has no attribute ‘ISelectionFilter’ [’ File “”, line 17, in \n’]
State: Warning
Mr. Poupin’s code and yours are similar
on the class of the Filter (I may not be using the right term)
Passing filter is not done (Must have some relation with CPython3)
We have on the backlog work to update these components and some of them have been fixed on the PythonNET side Sadly no ETA as we can’t give that out, but we’re aware, and it’s in queue!