View3D Class


Class for 3D views

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 16.0.0.0 (16.0.0.0)

Syntax

C#
public class View3D : View
Visual Basic
Public Class View3D _
	Inherits View
Visual C++
public ref class View3D : public View

Examples

Copy C#
private void Getinfo_View3D(View3D view3D)
{
    string message = "View3D: ";

    // The position of the camera.
    XYZ eyePosition = view3D.GetOrientation().EyePosition;
    message += "\nCamera position: " + eyePosition;

    // Identifies whether the view is a perspective view. 
    if (view3D.IsPerspective)
    {
        message += "\nThe view is a perspective view.";
    }

    // The section box of the 3D view can cut the model.
    if (view3D.IsSectionBoxActive)
    {
        BoundingBoxXYZ sectionBox = view3D.GetSectionBox();

        // Note that the section box can be rotated and transformed.  
        // So the min/max corners coordinates relative to the model must be computed via the transform.
        Transform trf = sectionBox.Transform;

        XYZ max = sectionBox.Max; //Maximum coordinates (upper-right-front corner of the box before transform is applied).
        XYZ min = sectionBox.Min; //Minimum coordinates (lower-left-rear corner of the box before transform is applied).

        // Transform the min and max to model coordinates
        XYZ maxInModelCoords = trf.OfPoint(max);
        XYZ minInModelCoords = trf.OfPoint(min);

        message += "\nView has an active section box: ";
        message += "\n'Maximum' coordinates: " + maxInModelCoords;
        message += "\n'Minimum' coordinates: " + minInModelCoords;
    }
    TaskDialog.Show("Revit", message);
}
Copy VB.NET
Private Sub Getinfo_View3D(view3D As View3D)
    Dim message As String = "View3D: "
    ' The position of the camera.
    Dim eyePosition As XYZ = view3D.GetOrientation().EyePosition
    message += ((vbLf & "Camera position: (" + eyePosition.X & ", ") + eyePosition.Y & ", ") + eyePosition.Z & ")"

    ' Identifies whether this is a perspective view. 
    If view3D.IsPerspective Then
        message += vbLf & "The view is a perspective."
    End If

    ' The section box of the 3D view cuts the model by its bounds.
    Dim sectionBox As BoundingBoxXYZ = view3D.GetSectionBox()
    Dim max As XYZ = sectionBox.Max
    'Maximum coordinates (upper-right-front corner of the box).
    Dim min As XYZ = sectionBox.Min
    'Minimum coordinates (lower-left-rear corner of the box).
    message += vbLf & "Section Box: "
    message += ((vbLf & "Maximum coordinates: (" + max.X & ", ") + max.Y & ", ") + max.Z & ")"
    message += ((vbLf & "Minimum coordinates: (" + min.X & ", ") + min.Y & ", ") + min.Z & ")"

    TaskDialog.Show("Revit", message)
End Sub

Inheritance Hierarchy

See Also