框选的方式分两种:
左上->右下,必须整体选中。
右下->左上,只要部分选中。
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 ;
}
}
{
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 ;
}
}