CreateElement Method


Create a DirectShape object and add it to document.

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

Syntax

C#
public static DirectShape CreateElement(
	Document document,
	ElementId categoryId,
	string appGUID,
	string appDataGUID
)
Visual Basic
Public Shared Function CreateElement ( _
	document As Document, _
	categoryId As ElementId, _
	appGUID As String, _
	appDataGUID As String _
) As DirectShape
Visual C++
public:
static DirectShape^ CreateElement(
	Document^ document, 
	ElementId^ categoryId, 
	String^ appGUID, 
	String^ appDataGUID
)

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.
appGUID
Type: System String
Identifies the creating application. May not be empty.
appDataGUID
Type: System String
Optional, to be used by the creating application. The intended use is to identify the native data that was the source of this DirectShape.

Return Value

DirectShape object if created successfully, NULL otherwise

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentException Element id categoryId does not correspond to a top-level built-in model category.
Autodesk.Revit.Exceptions ArgumentNullException A non-optional argument was NULL

See Also