Hi,
So here is the scenario. I have a file with a single rectangular beam[str.rvt]. Then I have another file[arch.rvt] in which I have linked the file with a single beam. I create a wall in arch.rvt in a way that the beam passes through the wall. With my main document being arch.rvt and linked model being str.rvt I try to find the elements which intersect/touches/crosses and the intersecting points with the following code which doesn't return the beam;
foreach (Wall wall in new FilteredElementCollector(doc).OfClass(typeof(Wall))) { Dictionary<Reference, XYZ> dict = GetIntersectPoints(doc, wall); } public Dictionary<Reference, XYZ> GetIntersectPoints( Document doc, Element intersect) { // Find a 3D view to use for the // ReferenceIntersector constructor. FilteredElementCollector collector = new FilteredElementCollector(doc); Func<View3D, bool> isNotTemplate = v3 => !(v3.IsTemplate); View3D view3D = collector .OfClass(typeof(View3D)) .Cast<View3D>() .First<View3D>(isNotTemplate); // Use location point as start point for intersector. LocationCurve lp = intersect.Location as LocationCurve; XYZ startPoint = lp.Curve.GetEndPoint(0) as XYZ; XYZ endPoint = lp.Curve.GetEndPoint(1) as XYZ; // Shoot intersector along element. XYZ rayDirection = endPoint.Subtract( startPoint).Normalize(); List<BuiltInCategory> builtInCats = new List<BuiltInCategory>(); builtInCats.Add(BuiltInCategory.OST_StructuralFraming); ElementMulticategoryFilter intersectFilter = new ElementMulticategoryFilter(builtInCats); ReferenceIntersector refIntersector = new ReferenceIntersector(intersectFilter, FindReferenceTarget.All, view3D); refIntersector.FindReferencesInRevitLinks = true; IList<ReferenceWithContext> referencesWithContext = refIntersector.Find(startPoint, rayDirection); IList<XYZ> intersectPoints = new List<XYZ>(); IList<Reference> intersectRefs = new List<Reference>(); Dictionary<Reference, XYZ> dictProvisionForVoidRefs = new Dictionary<Reference, XYZ>(); foreach (ReferenceWithContext r in referencesWithContext) { dictProvisionForVoidRefs.Add(r.GetReference(), r.GetReference().GlobalPoint); } return dictProvisionForVoidRefs; }
Thanks & Regards
Sanjay Pandey
I assume that the reference intersector view must belong to the same document as the element you are searching for.
If you have a linked file, you will probably have to translate the wall bounding box back into the corresponding location in the linked file coordinate system.
Just guessing!
Cheers,
Jeremy
Hi,
maybe you need to add
builtInCats.Add(BuiltInCategory.OST_RvtLinks);
to find also the RevitLinkInstances themselves.
Revitalizer
Hi,
the Wall's location line is on its bottom.
You will never find the beam if it does not really cross this ray.
So either you use a set of rays inside the wall and parallel to the wall's location curve, like a comb, like the horizontal lines in the letter E.
Or you can change the approach by using the beam's curve to find the wall(s) it hits.
Revitalizer
Hi,
things may become much clearer if you display the lines as ModelCurves.
So you can easily see the Wall's location curve and the ray you use.
Revitalizer