Is it possible to run ReferenceIntersector.FindNearest in a parallel for loop and avoid crash
Not applicable
02-28-2021
07:23 AM
Hello I tried to run ReferenceIntersector.FindNearest in a parallel for loop but revit always crash I would like to know if it is possible to run ReferenceIntersector.FindNearest in a parallel for loop and here is my normal for loop
ReferenceIntersector refIntersector = new ReferenceIntersector(IdFilter, FindReferenceTarget.Face, Get3DView(doc) as View3D);
for (int i = 0; i < points.Count; i++)
{
ReferenceWithContext referenceWithContext = refIntersector.FindNearest(points[i].OriginalPoint, points[i].OriginalPointNormal);
}
and here is my parallel for loop that crashes revit.
Parallel.For(0, points.Count , i =>
{
ReferenceWithContext referenceWithContext = refIntersector.FindNearest(points[i].OriginalPoint, points[i].OriginalPointNormal);
});
Link copied