public static bool IsElementExtied(Document doc, XYZ point, BuiltInCategory builtInCategory)
{
Outline outLine = new Outline(new XYZ(point.X - 1, point.Y - 1, point.Z - 1), new XYZ(point.X + 1, point.Y + 1, point.Z + 1));
BoundingBoxIntersectsFilter filter = new BoundingBoxIntersectsFilter(outLine, false);
FilteredElementCollector collector = new FilteredElementCollector(doc);
IList<Element> elems = collector.OfCategory(builtInCategory).WherePasses(filter).ToElements();
if (elems.Count > 0)
{
return true;
}
return false;
}
BoundingBoxIntersectsFilter此过滤有时候获取到的过滤元素并不一定真的相交