Revit 2024 API |
ViewDrafting..::..Create Method |
ViewDrafting Class Example See Also |
Creates a new ViewDrafting in the model.
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 24.0.0.0 (24.0.0.0)
Since:
2015
Syntax
C# |
---|
public static ViewDrafting Create( Document document, ElementId viewFamilyTypeId ) |
Visual Basic |
---|
Public Shared Function Create ( _ document As Document, _ viewFamilyTypeId As ElementId _ ) As ViewDrafting |
Visual C++ |
---|
public: static ViewDrafting^ Create( Document^ document, ElementId^ viewFamilyTypeId ) |
Parameters
- document
- Type: Autodesk.Revit.DB..::..Document
The document in which the new drafting view will be created.
- viewFamilyTypeId
- Type: Autodesk.Revit.DB..::..ElementId
The id of the ViewFamilyType that should be assigned to the new drafting view.
Return Value
The newly created drafting view.
Examples

// For simplicity, we'll look what drafting view types are already available, // and we'll use the first one we can find to create our new drafting view. FilteredElementCollector collector = new FilteredElementCollector(document); collector.OfClass(typeof(ViewFamilyType)); ViewFamilyType viewFamilyType = collector.Cast<ViewFamilyType>().First(vft => vft.ViewFamily == ViewFamily.Drafting); // Create a new ViewDrafting instance ViewDrafting view = ViewDrafting.Create(document, viewFamilyType.Id); view.Name = "MyViewDrafting"; // Set the CropBox BoundingBoxXYZ boundingBox = new BoundingBoxXYZ(); boundingBox.Max = new XYZ(100, 100, 50); boundingBox.Min = new XYZ(-100, -100, -50); view.CropBox = boundingBox;

' For simplicity, we'll look what drafting view types are already available, ' and we'll use the first one we can find to create our new drafting view. Dim collector As New FilteredElementCollector(document) collector.OfClass(GetType(ViewFamilyType)) Dim viewFamilyType As ViewFamilyType = collector.Cast(Of ViewFamilyType)().First(Function(vft) vft.ViewFamily = ViewFamily.Drafting) ' Create a new ViewDrafting instance Dim view As ViewDrafting = ViewDrafting.Create(document, viewFamilyType.Id) view.Name = "MyViewDrafting" ' Set the CropBox Dim boundingBox As New BoundingBoxXYZ() boundingBox.Max = New XYZ(100, 100, 50) boundingBox.Min = New XYZ(-100, -100, -50) view.CropBox = boundingBox
Exceptions
Exception | Condition |
---|---|
Autodesk.Revit.Exceptions..::..ArgumentException | viewFamilyTypeId is not a valid ViewFamilyType for a drafting view. |
Autodesk.Revit.Exceptions..::..ArgumentNullException | A non-optional argument was null |