Message 1 of 12
Unexpected behavior: SlabEdge not collected by ElementIntersectsSolidFilter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
It seems that SlabEdge behaves unexpectedly when I tried to filter for it with an ElementIntersectsSolidFilter. It is ignored even when it should intersect with a solid. I created a thin slice of solid by extruding the crop shape of a view, and expect both the 356884 (Floor) and 356986 (SlabEdge) to intersect with this solid, but only the former gets collected, the latter did not, as shown in the dialog running this code. The expectation is both 356884 and 356986 are collected from the ElementIntersectsSolidFilter, a reasonable expectation isn't it?
(I included a minimal Rvt file to reproduce this). Any help is appreciated!
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class ExternalCommand : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
var doc = commandData.View?.Document;
if (null == doc)
{
return Result.Cancelled;
}
var view = doc.ActiveView;
ViewCropRegionShapeManager cropRegionShapeManager = view.GetCropRegionShapeManager();
IList<CurveLoop> CropShape = cropRegionShapeManager.GetCropShape();
Solid slice = GeometryCreationUtilities.CreateExtrusionGeometry(CropShape, view.ViewDirection.Negate(), 0.1);
FilteredElementCollector allelements = new FilteredElementCollector(doc, doc.ActiveView.Id);
FilteredElementCollector intersected = new FilteredElementCollector(doc, doc.ActiveView.Id)
.WherePasses(new ElementIntersectsSolidFilter(slice));
MessageBox.Show($"All Elements:\n{ElementsToString(allelements)}\n\n" +
$"\nIntersected Elements:\n{ElementsToString(intersected)}");
return Result.Succeeded;
}
private string ElementsToString(FilteredElementCollector collector)
{
return string.Join(",\n", collector.ToElements().Select(e => $"{e.Id} {e.Category?.Name} - {e.Name}"));
}
}