DirectShapeCreateElementInstance Method |
Creates a DirectShape object and adds it to document.
Namespace: Autodesk.Revit.DBAssembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntaxpublic static DirectShape CreateElementInstance(
Document document,
ElementId typeId,
ElementId categoryId,
string definitionId,
Transform trf
)
Public Shared Function CreateElementInstance (
document As Document,
typeId As ElementId,
categoryId As ElementId,
definitionId As String,
trf As Transform
) As DirectShape
public:
static DirectShape^ CreateElementInstance(
Document^ document,
ElementId^ typeId,
ElementId^ categoryId,
String^ definitionId,
Transform^ trf
)
static member CreateElementInstance :
document : Document *
typeId : ElementId *
categoryId : ElementId *
definitionId : string *
trf : Transform -> DirectShape
Parameters
- document Document
-
Document to which the created element will be added.
- typeId ElementId
-
Element id of a DirectShapeType element.
- categoryId ElementId
-
Id of the category assigned to this DirectShape. Must be a valid category id.
- definitionId String
-
Id of the shape definition that was created earlier and stored via DirectShapeLibrary.
- trf Transform
-
Transform to be applied to the definition.
Return Value
DirectShape
The created DirectShape object.
ExceptionsException | Condition |
---|
ArgumentException |
Document document may not contain DirectShape or DirectShapeType objects.
-or-
Element id categoryId may not be used as a DirectShape category.
|
ArgumentNullException |
A non-optional argument was null
|
Remarks
This function is included for convenience. It essentially combines CreateGeometryInstance and CreateElement.
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.
The intended use is 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.
See Also