- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This should be easy to do but I cannot find the solution.
I need to test if a XYZ in world coordinates can be projected on a face of the 3D geometry of a familyinstance, and if so what the coordinates are relative to the low left corner of that face.
My code gets the GeometryInstance of the family (it does not make much difference if I use GetInstanceGeometry or GetSymbolGeometry for this). Then I filter out the Solids that meet certain conditions and from those I filter out the Faces that meet certain conditions.
I then use XYZ ocsXYZ = FamilyInstance.GetTotalTransform().Inverse.OfPoint(worldXYZ); to get the world coordinate in the local coordinate system of the family.
I can then use Face.Project(ocsXYZ); to find if the point can be projected on the face and what the UV is of that projected point for the coordinates relative to the face origin (and from there I can correct it to be relative to the low left corner of the face).
This is a lazy method but it worked fine until recently, when a customer reported an error with this part of the code. Even though the wcs point visibly should project on a face of that family instance, the code could not find one.
It turned out that the customer had the relevant 3D geometry in a nested family, and rotated and mirrored that instance.
The geometry instance has the 3D coordinates of the face relative to the definition of the family they are defined in. And the GetTotalTransform() only returns the transform for top level family to world coordinates.
There is a missing Transform here, or potentially many if the geometry is more deeply nested.
Using GetTransformedCopy() on the GeometryInstance will not work because the only transform I have is of the top level family instance, and it will not take into account the effect of the transforms of the nested instances.
I can of course open each family in an editor to find the transform of the nested elements, but that seems incredibly inefficient to me.
Given that revit itself has no problem working with nested geomerty, no matter how the nested instances are transformed, there must be a better solution readily available. I hope that somebody knows and can give me a hint of where to look for it.
Thanks in advance,
Mark de Vries
ICN Development
Solved! Go to Solution.