Returns a new perspective View3D.
Namespace: Autodesk.Revit.DBAssembly: RevitAPI (in RevitAPI.dll) Version: 23.0.0.0 (23.1.0.0)
Since: 2013
Syntax
C# |
---|
public static View3D CreatePerspective( Document document, ElementId viewFamilyTypeId ) |
Visual Basic |
---|
Public Shared Function CreatePerspective ( _ document As Document, _ viewFamilyTypeId As ElementId _ ) As View3D |
Visual C++ |
---|
public: static View3D^ CreatePerspective( Document^ document, ElementId^ viewFamilyTypeId ) |
Parameters
- document
- Type: Autodesk.Revit.DB..::..Document
The document to which the new View3D will be added.
- viewFamilyTypeId
- Type: Autodesk.Revit.DB..::..ElementId
The id of the ViewFamilyType which will be used by the new View3D. The type needs to be a ThreeDimensional ViewType.
Return Value
The new perspective View3D.
Remarks
The new View3D will receive a unique view name. The view will be oriented in the same position as the default 3D view.
Examples

' Find a 3D view type Dim collector1 As New FilteredElementCollector(document) collector1 = collector1.OfClass(GetType(ViewFamilyType)) Dim viewFamilyTypes As IEnumerable(Of ViewFamilyType) viewFamilyTypes = From elem In collector1 _ Let vftype = TryCast(elem, ViewFamilyType) _ Where vftype.ViewFamily = ViewFamily.ThreeDimensional _ Select vftype ' Create a new Perspective View3D Dim view3D__1 As View3D = View3D.CreatePerspective(document, viewFamilyTypes.First().Id) If view3D__1 IsNot Nothing Then ' By default, the 3D view uses a default orientation. ' Change the orientation by creating and setting a ViewOrientation3D Dim eye As New XYZ(0, -100, 10) Dim up As New XYZ(0, 0, 1) Dim forward As New XYZ(0, 1, 0) view3D__1.SetOrientation(New ViewOrientation3D(eye, up, forward)) ' turn off the far clip plane with standard parameter API Dim farClip As Parameter = view3D__1.LookupParameter("Far Clip Active") farClip.[Set](0) End If
Exceptions
Exception | Condition |
---|---|
Autodesk.Revit.Exceptions..::..ArgumentException | This View Family Type is not a ThreeDimensional view type. -or- 3D view creation is not allowed in this family. |
Autodesk.Revit.Exceptions..::..ArgumentNullException | A non-optional argument was null |
Autodesk.Revit.Exceptions..::..ModificationForbiddenException | The document is in failure mode: an operation has failed, and Revit requires the user to either cancel the operation or fix the problem (usually by deleting certain elements). -or- The document is being loaded, or is in the midst of another sensitive process. |
Autodesk.Revit.Exceptions..::..ModificationOutsideTransactionException | The document has no open transaction. |