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