RVTDocs.com
Namespace: Autodesk.Revit.DB Class: ViewDrafting

ViewDrafting.Create

Method
Description:
Creates a new ViewDrafting in the model.
Syntax
public static ViewDrafting Create(
	Document document,
	ElementId viewFamilyTypeId
)
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;
Parameters
Parameter Type Description
document Document The document in which the new drafting view will be created.
viewFamilyTypeId ElementId The id of the ViewFamilyType that should be assigned to the new drafting view.
Return Value
Type Description
ViewDrafting The newly created drafting view.
Exceptions
Exception Condition
ArgumentException viewFamilyTypeId is not a valid ViewFamilyType for a drafting view.
ArgumentNullException A non-optional argument was null