Message 1 of 4
BoundingBoxIntersectsFilter with linked model
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm trying to build a code that checks if an element in the current model (host model) clashes with any elements in a linked model.
However, the code seems only to capture the intersection between the element and the 3D view camera in the linked model, which makes sense as the 3D view is very large.
Does anyone know the potential reason? I tried both transform and transform.inverse without success. Has anyone successfully used this filter to identify clashes with elements in a linked model? Thank you.
var element_bbox = element.get_BoundingBox(null);
// Transform the points to the linked model's coordinate system
XYZ point_min_transformed = linkInstance.GetTransform().Inverse.OfPoint(element_bbox.Min);
XYZ point_max_transformed = linkInstance.GetTransform().Inverse.OfPoint(element_bbox.Max);
//XYZ point_min_transformed = element_bbox.Min;
//XYZ point_max_transformed = element_bbox.Max;
// Ensure min and max points are valid
double minX = Math.Min(point_min_transformed.X, point_max_transformed.X);
double minY = Math.Min(point_min_transformed.Y, point_max_transformed.Y);
double minZ = Math.Min(point_min_transformed.Z, point_max_transformed.Z);
double maxX = Math.Max(point_min_transformed.X, point_max_transformed.X);
double maxY = Math.Max(point_min_transformed.Y, point_max_transformed.Y);
double maxZ = Math.Max(point_min_transformed.Z, point_max_transformed.Z);
// Create new XYZ points with corrected coordinates
XYZ correctedMin = new XYZ(minX, minY, minZ);
XYZ correctedMax = new XYZ(maxX, maxY, maxZ);
Outline myOutLn_transformed = new Outline(correctedMin, correctedMax);
// Create the bounding box filter
BoundingBoxIntersectsFilter element_bbox_filter = new BoundingBoxIntersectsFilter(myOutLn_transformed);
FilteredElementCollector collector = new FilteredElementCollector(linkInstance.GetLinkDocument());
IList<Element> potentiallyClashingLinkElements = collector.WhereElementIsNotElementType().WherePasses(element_bbox_filter).Where(e => e.Category != null && e.Category.CategoryType == CategoryType.Model).ToList();