Creates a DirectShape object and adds it to document.
Namespace: Autodesk.Revit.DBAssembly: RevitAPI (in RevitAPI.dll) Version: 21.0.0.0 (21.1.1.109)
Since: 2017
Syntax
| C# | 
|---|
public static DirectShape CreateElement( Document document, ElementId categoryId )  | 
| Visual Basic | 
|---|
Public Shared Function CreateElement ( _ document As Document, _ categoryId As ElementId _ ) As DirectShape  | 
| Visual C++ | 
|---|
public: static DirectShape^ CreateElement( Document^ document, ElementId^ categoryId )  | 
Parameters
- document
 - Type: Autodesk.Revit.DB..::..Document
Document to which the created element will be added. 
- categoryId
 - Type: Autodesk.Revit.DB..::..ElementId
Id of the category assigned to this DirectShape. Must be a valid category id. 
Return Value
The created DirectShape object.
Exceptions
| Exception | Condition | 
|---|---|
| Autodesk.Revit.Exceptions..::..ArgumentException | Document document may not contain DirectShape or DirectShapeType objects. -or- Element id categoryId may not be used as a DirectShape category. | 
| Autodesk.Revit.Exceptions..::..ArgumentNullException | A non-optional argument was NULL |