Revit二次开发之“框选”过滤

这里的框选,必须是整体选中。
框选的方式分两种:
左上->右下,必须整体选中。
右下->左上,只要部分选中。
public void SelectPlanarFaces(Autodesk.Revit.DB.Document document)
{
    UIDocument uidoc 
= new UIDocument(document);
    ISelectionFilter selFilter 
= new PlanarFacesSelectionFilter(document);
    IList
<Reference> faces = uidoc.Selection.PickObjects(ObjectType.Face, selFilter, "Select multiple planar faces");
}

public class PlanarFacesSelectionFilter : ISelectionFilter
{
    Document doc 
= null;
    
public PlanarFacesSelectionFilter(Document document)
    {
        doc 
= document;
    }

    
public bool AllowElement(Element element)
    {
        
return true;
    }

    
public bool AllowReference(Reference refer, XYZ point)
    {   
        
if (doc.GetElement(refer).GetGeometryObjectFromReference(refer) is PlanarFace)
        {
            
return true// Only return true for planar faces. Non-planar faces will not be selectable
        }
        
return false;
    }
}
url:http://revit.5d6d.com/thread-873-1-4.html
posted @ 2011-08-01 08:00  大气象  阅读(1994)  评论(0编辑  收藏  举报
http://www.tianqiweiqi.com