
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello there!
I seem to have a peculiar problem:
I'm trying to compute the intersections of several SurfaceBody instances with a plane and then convert the resulting edges of the intersection bodies to 2D approximations in the plane's local space.
The intersection part works fine. The only "issue" is that the TransientBRep.CreateIntersectionWithPlane(...) method throws an exception if there is no intersection between the body and the plane and those exceptions clutter my debug output, but that's not really a problem.
The problem comes up in the next step: Since I can't find a way to get a 2D projection on the plane of the 3D curves of the intersection's edges directly, I tried to get a linear approximation of each edge and project the points of this approximation onto my plane.
Sadly, getting the linear approximation of these edges seems to be nigh impossible. I tried three approaches:
a) Use the CalculateStrokes method of the edge directly:
foreach (Edge edge in intersectionBody.Edges) { try { int vertexCount, segmentCount; double[] vertexCoords = { }; int[] vertexIndices = { }; edge.CalculateStrokes(tolerance, out vertexCount, out segmentCount, out vertexCoords, out vertexIndices); // immediate crash } catch (System.Exception ex) { ... } }
b) Use the GetStrokes method of the edge's geometry's evaluator:
foreach (Edge edge in intersectionBody.Edges) { try { CurveEvaluator eval = edge.Geometry.Evaluator; double minParam, maxParam, length; eval.GetParamExtents(out minParam, out maxParam); int vertexCount; double[] vertexCoords = { }; eval.GetStrokes(minParam, maxParam, tolerance, out vertexCount, out vertexCoords); // immediate crash } catch (System.Exception ex) { ... } }
c) Use the TransientGeometry.CreatePolyline3dFromCurve method.
foreach (Edge edge in intersectionBody.Edges) { try { Polyline3d pl = tGeo.CreatePolyline3dFromCurve(edge.Geometry, tolerance); // throws an exception } catch (System.Exception ex) { ... } }
Both a) and b) result in an immediate crash of Inventor with no way for me to catch the exception. c) throws an exception, meaning I can actually catch that one and keep Inventor from crashing immediately.
Since a) and b) crash immediately I can't tell if they would work for other edges in the body. c) doesn't work for any of the edges.
My current workaround is to use the CurveEvaluator to get a ridiculous number of points and filter those based on my tolerance. This is pretty inefficient and actually takes a lot longer than the intersection computation does, so it's not a real option in the long run.
Can anybody help me with this issue?
Solved! Go to Solution.