Revit secondary development filter

door filter

    public class DoorFilter : ISelectionFilter
    {
    
    
        public bool AllowElement(Element elem)
        {
    
    
            if (elem is FamilyInstance && elem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Doors)
            {
    
    
                return true;
            }
            return false;
        }

        public bool AllowReference(Reference reference, XYZ position)
        {
    
    
            return true;
        }
    }

wall filter

public class WallFilter : ISelectionFilter
{
    
    
    public bool AllowElement(Element elem)
    {
    
    
        return elem is Wall;
    }

    public bool AllowReference(Reference reference, XYZ position)
    {
    
    
        return true;
    }
}

room filter

public class RoomFilter : ISelectionFilter
{
    
    
    public bool AllowElement(Element elem)
    {
    
    
        if (elem is Room)
        {
    
    
            return true;
        }
        return false;
    }

    public bool AllowReference(Reference reference, XYZ position)
    {
    
    
        return true;
    }
}

Guess you like

Origin blog.csdn.net/ultramand/article/details/130592592