The Autodesk.Revit.DB.ViewOrientation3D class represents the orientation of a 3D view in Revit. It is a subclass of the Autodesk.Revit.DB.ViewOrientation class and inherits all of its properties and methods.
EyePosition
- A XYZ point that represents the position of the viewer's eye.LookDirection
- A XYZ vector that represents the direction the viewer is looking.UpDirection
- A XYZ vector that represents the upward direction for the viewer.The Autodesk.Revit.DB.ViewOrientation3D class contains no additional methods beyond those inherited from the Autodesk.Revit.DB.ViewOrientation class.
The Autodesk.Revit.DB.ViewOrientation3D class can be used to programmatically set and retrieve the orientation of a 3D view in Revit. It can be accessed from a View3D object using the View3D.GetOrientation()
method. Once retrieved, the properties of the ViewOrientation3D object can be modified to set the desired view orientation, and then the updated orientation can be applied to the View3D using the View3D.SetOrientation()
method.
// Retrieve a View3D object
View3D myView3D = new FilteredElementCollector(doc)
.OfClass(typeof(View3D))
.OfType<View3D>()
.First();
// Retrieve the current view orientation
ViewOrientation3D orientation = myView3D.GetOrientation();
// Modify the view orientation
orientation.EyePosition = new XYZ(0, 100, 0);
orientation.LookDirection = new XYZ(0, -1, 0);
orientation.UpDirection = new XYZ(0, 0, 1);
// Apply the updated orientation to the View3D
myView3D.SetOrientation(orientation);