Distance point to solid

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi forum,
I would like to ask the gurus here about the possibilities to perform the task of computing the distance of a point to an arbitrary solid.
My current approach is the following:
1. Try to get the correct transformation of the solid (which seems to be quite non-straight-forward depending on where the solid comes from -- GeometryElements, GeometryInstances, FamilyInstances, Pipes, Windows, whatever...)
2. Also restrict points to a BoundingBox to optimize, but BoundingBoxes are only axis-parallel for some of the instances I'm handling and so they are helping only in a subset of cases.
3. Get all the faces, edges and vertices (Edge.GetEndPointReference) from the solid and store them for repeated distance requests with different points
4. For a given point calculate projective distances to the Faces, Edges and Vertices of the Solid (via XYZ.DistanceTo, Face.Project, Edge.Project, since this is the only working possibility I found in the API).
5. return the Minimum of all these distances.
This is working as expected but it is a lot of code and it is very slow - especially if one does repeated distance calculations with a lot of points, which I do.
So my question to you is:
Is there something better?
Does the API provide native means to speed up this process?
Is there maybe some Solid.DistanceTo method or similar hidden somewhere in the API?
I know of the ReferenceIntersector and I used it for an InsideCheck between point and Solid. Is there something similar that can be used for distance computation?
The ultimate problem we are facing is to find out, if a point has a certain distance r from the solid. So it would be possible to reformulate the problem as an intersection of the Solid and a Sphere of radius r around the given point. Is it possible to create a sphere through the API and intersect it with the solid? Are there any alternative approaches?
Any ideas and suggestions are highly appreciated.
Thanks a lot in advance and all the best,
Martin