Message 1 of 2
ComputeClosestPoints in nested forloop crashing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all, I'm trying to iterate through a nested forloop of DetailLines and call ComputeClosestPoints to see if any lines in those 2 lists match my requirements.
It runs the first time, I then clear the list but I still get the error below. Is there a way to run through again without getting the InvalidOperationException Error? This is one of my first times using ComputeClosestPoints(). I'm still learning it.
I've checked the API docs, and this other post but they don't mention anything about being able to iterate through it a second time.
Any and all help is appreciated.
When I call ComputeClosestPoints the second time around, I get an error:
Exception thrown: 'Autodesk.Revit.Exceptions.InvalidOperationException' in RevitAPI.dll
An exception of type 'Autodesk.Revit.Exceptions.InvalidOperationException' occurred in RevitAPI.dll but was not handled in user code
Additional information: The method failed. For example the problem has infinitely many solutions such as two parallel lines or two concentric circles.
Here is my code:
List<DetailLine> testLines1;
List<DetailLine> testLines2;
for (int i = 0; i < testLines1.Count; i++)
{
for (int k = 0; k < testLines2.Count; k++)
{
IList<ClosestPointsPairBetweenTwoCurves> resultPoints = new
List<ClosestPointsPairBetweenTwoCurves>();
testLines1[i].GeometryCurve.ComputeClosestPoints(testLines2[k].GeometryCurve, true, true, true, out resultPoints);
resultPoints.Clear();
}
}