CreateElementInstance Method


Create a DirectShape object and add it to document. The shape stored in the element is either a reference or a copy of a definition shape that was created earlier. How the definitions are stored will determine whether an instance or a copy of the shape will be created. See DirectShapeLibrary for more details. This function is included for convenience. It essentially combines CreateGeometryInstance and CreateElement.

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 CreateElementInstance(
	Document document,
	ElementId typeId,
	ElementId categoryId,
	string definition_id,
	Transform trf,
	string appGUID,
	string appDataGUID
)
Visual Basic
Public Shared Function CreateElementInstance ( _
	document As Document, _
	typeId As ElementId, _
	categoryId As ElementId, _
	definition_id As String, _
	trf As Transform, _
	appGUID As String, _
	appDataGUID As String _
) As DirectShape
Visual C++
public:
static DirectShape^ CreateElementInstance(
	Document^ document, 
	ElementId^ typeId, 
	ElementId^ categoryId, 
	String^ definition_id, 
	Transform^ trf, 
	String^ appGUID, 
	String^ appDataGUID
)

Parameters

document
Type: Autodesk.Revit.DB Document
Document to which the created element will be added
typeId
Type: Autodesk.Revit.DB ElementId
Element id of a DirectShapeType element.
categoryId
Type: Autodesk.Revit.DB ElementId
Id of the category assigned to this DirectShape. Must be a valid category id.
definition_id
Type: System String
ID of the shape definition that was created earlier and stored via DirectShapeLibrary
trf
Type: Autodesk.Revit.DB Transform
Transform to be applied to the definition
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

Remarks

This is intended to support a definition/instance pattern common in CAD formats - DWG blocks, STEP MAPPED_ITEM, IFC IfcMappedItem. Use DirectShapeLibrary class to store definitions prior to using them here.

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