40 lines
919 B
Plaintext
40 lines
919 B
Plaintext
|
|
using Autodesk.Revit.UI.Selection;
|
||
|
|
|
||
|
|
ISelectionFilter selFilter = new PlanarFacesSelectionFilter(doc);
|
||
|
|
try
|
||
|
|
{
|
||
|
|
IList<Reference> faces = uidoc.Selection.PickObjects(ObjectType.Face, selFilter, "选择多个平面");
|
||
|
|
foreach (var face in faces)
|
||
|
|
{
|
||
|
|
Print(face.GlobalPoint.ToString());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
catch(Exception ex)
|
||
|
|
{
|
||
|
|
Print(ex.Message);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
private class PlanarFacesSelectionFilter : ISelectionFilter
|
||
|
|
{
|
||
|
|
private readonly 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; // 只有平面可以选择,其他无法被选择
|
||
|
|
}
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|