CreateElement Method


Creates a DirectShape object and adds it to document.

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

Syntax

C#
[ObsoleteAttribute("This function will be obsolete in Revit 2017. Use DirectShape.CreateElement(Document, ElementId) instead. Use DirectShape.ApplicationId, DirectShape.ApplicationDataId properties to set application id and application data id.")]
public static DirectShape CreateElement(
	Document document,
	ElementId categoryId,
	string applicationId,
	string applicationDataId
)
Visual Basic
<ObsoleteAttribute("This function will be obsolete in Revit 2017. Use DirectShape.CreateElement(Document, ElementId) instead. Use DirectShape.ApplicationId, DirectShape.ApplicationDataId properties to set application id and application data id.")> _
Public Shared Function CreateElement ( _
	document As Document, _
	categoryId As ElementId, _
	applicationId As String, _
	applicationDataId As String _
) As DirectShape
Visual C++
[ObsoleteAttribute(L"This function will be obsolete in Revit 2017. Use DirectShape.CreateElement(Document, ElementId) instead. Use DirectShape.ApplicationId, DirectShape.ApplicationDataId properties to set application id and application data id.")]
public:
static DirectShape^ CreateElement(
	Document^ document, 
	ElementId^ categoryId, 
	String^ applicationId, 
	String^ applicationDataId
)

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.
applicationId
Type: System String
An optional text string that identifies the creating application. May not be empty.
applicationDataId
Type: System String
An optional text string that identifies the data to the creating application. The intended use is to identify the native data that was the source of this DirectShape.

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

See Also