ISelectionFilter Interface


An interface that provides the ability to filter objects during a selection operation.

Namespace: Autodesk.Revit.UI.Selection
Assembly: RevitAPIUI (in RevitAPIUI.dll) Version: 2015.0.0.0 (2015.0.0.0)

Syntax

C#
public interface ISelectionFilter
Visual Basic
Public Interface ISelectionFilter
Visual C++
public interface class ISelectionFilter

Examples

Copy C#
public static IList<Element> GetManyRefByRectangle(UIDocument doc)
{
    ReferenceArray ra = new ReferenceArray();
    ISelectionFilter selFilter = new MassSelectionFilter();
    IList<Element> eList = doc.Selection.PickElementsByRectangle(selFilter, 
        "Select multiple faces") as IList<Element>;
    return eList;
}

public class MassSelectionFilter : ISelectionFilter
{
    public bool AllowElement(Element element)
    {
        if (element.Category.Name == "Mass")
        {
            return true;
        }
        return false;
    }

    public bool AllowReference(Reference refer, XYZ point)
    {
        return false;
    }
}
Copy VB.NET
Public Shared Function GetManyRefByRectangle(doc As UIDocument) As IList(Of Element)
    Dim ra As New ReferenceArray()
    Dim selFilter As ISelectionFilter = New MassSelectionFilter()
    Dim eList As IList(Of Element) = TryCast(doc.Selection.PickElementsByRectangle(selFilter, "Select multiple faces"), IList(Of Element))
    Return eList
End Function

Public Class MassSelectionFilter
    Implements ISelectionFilter
    Public Function AllowElement(element As Element) As Boolean Implements ISelectionFilter.AllowElement
        If element.Category.Name = "Mass" Then
            Return True
        End If
        Return False
    End Function

    Public Function AllowReference(refer As Reference, point As XYZ) As Boolean Implements ISelectionFilter.AllowReference
        Return False
    End Function
End Class

See Also