Message 1 of 6
What am I doing Wrong - FindReferencesInRevitLinks

Not applicable
02-22-2017
08:29 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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