DocumentDelete(ElementId) Method |
Deletes an element from the document given the id of that element.
Namespace: Autodesk.Revit.DBAssembly: RevitAPI (in RevitAPI.dll) Version: 26.0.4.0 (26.0.4.0)
Syntaxpublic ICollection<ElementId> Delete(
ElementId elementId
)
Public Function Delete (
elementId As ElementId
) As ICollection(Of ElementId)
public:
ICollection<ElementId^>^ Delete(
ElementId^ elementId
)
member Delete :
elementId : ElementId -> ICollection<ElementId>
Parameters
- elementId ElementId
-
Id of the element to delete.
Return Value
ICollectionElementId
The deleted element id set.
ExceptionsException | Condition |
---|
ArgumentException |
The element elementId does not exist in the document
-or-
ElementId cannot be deleted.
|
ArgumentNullException |
A non-optional argument was null
|
ModificationForbiddenException |
The document is in failure mode: an operation has failed,
and Revit requires the user to either cancel the operation
or fix the problem (usually by deleting certain elements).
-or-
The document is being loaded, or is in the midst of another
sensitive process.
|
ModificationOutsideTransactionException |
The document has no open transaction.
|
Remarks
This method will delete the element and any elements that are totally dependent upon that element. Any references to the deleted elements will become invalid and hence cause an exception to be thrown if they are accessed.
The elements will be deleted with no prompts for user confirmation. If pinned elements cannot be deleted before being unpinned, an exception will be thrown.
Note: in a family document, the predefined elements (those elements inherited from its family template file) can't be deleted by this method.
See Also