Family Instance Orientation

Family Instance Orientation

L.Maas
Mentor Mentor
5,212 Views
4 Replies
Message 1 of 5

Family Instance Orientation

L.Maas
Mentor
Mentor

I have some questions about the orientation of family instances. What I am trying to accomplish is to export an image of a family instance. For this I let the user select a family instance in the project. After that I create a new isometric 3D View, isolate that family instance and try to set the the isometric view relative to the orientation of that family. If I have non-hosted families this works fine. I can determine the rotation of the family instance (get locationpoint and from there the rotation). Something like (VB.NET)

 

 

Dim ElemPos As Location = FamInstance.Location
Dim ObjectLocationPoint As LocationPoint = TryCast(ElemPos, LocationPoint)
Dim ObjectRotation As Double = ObjectLocationPoint.Rotation

 

When I have the rotation I can orient the view accordingly (setorientation).

ViewAngle = 135 + ObjectRotation * (180 / Math.PI)

However I have difficulty to get the orientation/rotation of the family instance when they are wall/face based families.

 

How can I find the rotation of the family instance when it is a hosted element

 

Hereunder a sketch of what I am trying to do. Grey are non-hosted element green the (face/wall) based elements.

Views.png

The isometric 3D View should display something like

Views2.png

 

 

Louis

EESignature

Please mention Revit version, especially when uploading Revit files.

0 Likes
Accepted solutions (1)
5,213 Views
4 Replies
Replies (4)
Message 2 of 5

JimJia
Alumni
Alumni

Dear Louis,

 

You may try to use API FamilyInstance.FacingOrientation  or FamilyInstance.HandOrientation properties to verify if it works for you. 


Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
Message 3 of 5

L.Maas
Mentor
Mentor

Thanks.Have been looking at it. Might be part of the solution.

 

Not managed to get what I need yet. However that is because I am still struggling with all the transforms and matrix stuff. At the moment still fuzzy how things behave/move in the model and move in relation to what. I will need to do some tests and try to figure it out.

Louis

EESignature

Please mention Revit version, especially when uploading Revit files.

0 Likes
Message 4 of 5

L.Maas
Mentor
Mentor
Accepted solution

Finally managed to get results that seems to work (more testing needed). First of all I had a mistake in my code. At some point I tried to convert radians to degrees, however the supplied value was already in degrees, causing unexpected results Smiley Frustrated

.

 

Looking through lot of information, especially on the building coder website (@jeremytammik) I finally ended up with something that seems to work.

 

 

Dim Trf As DB.Transform = ElementListInstance.GetTransform()
Dim basX As XYZ = Trf.BasisX
Dim basZ As XYZ = Trf.BasisZ

Dim vectorTran As XYZ = Trf.OfVector(Trf.BasisX)
Dim ObjectRotation As Double = Trf.BasisX.AngleOnPlaneTo(vectorTran, Trf.BasisZ) * (180 / Math.PI)

Knowing the angle of the object allowed me to create a 3DView on a position relative to the selected object.

 

Louis

EESignature

Please mention Revit version, especially when uploading Revit files.

Message 5 of 5

sologubov_d_v
Explorer
Explorer
var objectRotation = XYZ.BasisX.AngleOnPlaneTo(familyInstanceTransform.BasisX, XYZ.BasisZ);