How to get correct rotation from Transforms of (Nested) Families

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey, I can't figure out how to get the same rotation value (as XYZ) from a Transform when using Transform.OfPoint(XYZ).
I'll try to explain, for example I'm exporting a family that has nested family placed on the Center Left/Right plane (see blow):
When I export its geometry by using Transform.OfPoint(XYZ) of each of its vertices, the position & rotation is correctly retrieved (the pyramid is pointing in the positive X direction, so west to east).
I got the origin of the transform as the local position of the nested family, but how do I get the rotation value from the Transform as a XYZ?
I tried to calculate it from the Transform using the following method:
public static XYZ getRotationFromTransform(Transform transform) { double x = Math.Atan2(transform.BasisZ.Y, transform.BasisZ.Z) * (180 / Math.PI); double y = Math.Atan2(transform.Inverse.BasisZ.X, Math.Sqrt((transform.BasisZ.Y * transform.BasisZ.Y) + (transform.BasisZ.Z * transform.BasisZ.Z))) * (180 / Math.PI); double z = Math.Atan2(transform.BasisY.X, transform.BasisX.X) * (180 / Math.PI); return new XYZ(x, y, z); }
But that seems to be wrong for nested family transforms.
The same seems to be true for the LocationPoint.Rotation value for nested families (or at least it is view based) as discussed here: http://thebuildingcoder.typepad.com/blog/2013/06/correct-detail-component-rotation-in-elevation-view... And that value is just a double, without any reference to what axis the rotation is happing on.
So how come the export result is good when using Transform.OfPoint(XYZ), but I can't get the XYZ rotation from the same Transform? In other words: How do I get the rotation from a FamilyInstance Transform?
If you have any questions, just ask and I'll try my best to give an answer or more information.