Than.7897
(Trung Thành)
November 7, 2023, 3:13am
1
I am working with python 3 in dynamo and i got stuck with ISelectionFilter. And i dont know why, even though a lot of code on the internet still working.
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = uiapp.ActiveUIDocument
class MySelectionFilter(ISelectionFilter):
def __init__(self):
pass
def AllowElement(self, element):
if element.Category.Name == "Walls":
return True
else:
return False
def AllowReference(self, element):
return False
selection_filter = MySelectionFilter()
wall = uidoc.Selection.PickObject(ObjectType.Element, selection_filter)
OUT = wall
The TypeError: interface takes exactly one argument
I think because the python 3 in dynamo revit 2024 does not support anymore.
Thank all.
Jean-Marc
(Jean-Marc Couffin)
November 7, 2023, 10:31am
2
Than.7897:
ISelectionFilter
Xinh Chao Anh Thanh!
pyrevit does not support python 3 that well yet.
the piece of code you provided misses the imports and seems to be a dynamo script. Not entirely the same framework, so it would need some tweaking depending on the import section
plenty of example all around about ISelectionFilter:
Hi, i am new on this forum (and in pyrevit). I watched all pyRevit tutorials and now i try to write my first “button”. So i start from easy project (but not easy for me…). I want to pick elements and linked elements in model, and then show the lists of them (i know there are few programs for this but this is learning project). I spent a lot of time (written few scripts) but nothing is change… I can’t extract and print the data. My script looks:
from Autodesk.Revit.DB import *
from Autodesk.Revi…
class CustomISelectionFilter(ISelectionFilter):
"""Filter user selection to certain element."""
def __init__(self, cats):
self.cats = cats
def AllowElement(self, e):
if str(e.Category.Id) == str(self.cats):
#if e.Category.Name == "Walls"
return True
return False
class ISelectionFilter_Classes(ISelectionFilter):
def __init__(self, allowed_types):
""" ISelectionFilter made to filter with types
:param allowed_types: list of allowed Types"""
self.allowed_types = allowed_types
def AllowElement(self, element):
if type(element) in self.allowed_types:
return True
The error you mention usually lists the line of the error, providing the full script + the full error text / providing context usually helps us provide with answer
Than.7897
(Trung Thành)
November 8, 2023, 3:14am
3
Thank you alot . But I found a lot of example for that, but it sill didn’t work in dynamo. even thought i saw some doing that sucessfully on youtube.
Jean-Marc
(Jean-Marc Couffin)
November 8, 2023, 7:30am
4
You are in the wrong forum then. If you plan on getting things to work in dynamo, then the dynamo forum is the place to ask.