Document.GetChangedElements
Method
Description:
Extracts a collection containing the ids of elements that have been created, modified or deleted between the input baseVersion and the document's current version.
Extracts a collection containing the ids of elements that have been created, modified or deleted between the input baseVersion and the document's current version.
Examples
private void ShowChangedElements(Autodesk.Revit.DB.Document document, Guid baseVerseionGuid)
{
//Parameter baseVersionGuid is retrieved from property VersionGUID of Autodesk.Revit.DB.DocumentVersion.
//System.Guid.Empty is allowed to get all changes in document.
DocumentDifference docDiff = document.GetChangedElements(baseVerseionGuid);
if (docDiff.AreDeletedElementIdsAvailable)
{
TaskDialog.Show("Revit", "Deleted element history is available in current document.");
}
else
{
TaskDialog.Show("Revit", "Deleted element history is not available in current document.");
}
// New added elements.
var createdElementIds = docDiff.GetCreatedElementIds();
// Modified elements.
var modifiedElementIds = docDiff.GetModifiedElementIds();
// Deleted elements.
// For nonworkshared model, always returns an empty collection.
var deletedElementIds = docDiff.GetDeletedElementIds();
var changesetMessage = $"Found {createdElementIds.Count} new created elements, {modifiedElementIds.Count} modified elements and {deletedElementIds.Count} deleted elements.";
TaskDialog.Show("Revit", changesetMessage);
}
Parameters
Parameter | Type | Description |
---|---|---|
baseVersionGUID | Guid | GUID of base version(excluded) to compare. This GUID should be retrieved from property <span class="noLink">[!:Autodesk::Revit::DB::DocumentVersion::VersoinGUID]</span>. Empty GUID is allowed to retrieve changes of each version in the document. |
Return Value
Type | Description |
---|---|
DocumentDifference | An object containing collections of the created, modified and deleted ids between the input version and current version. |
Exceptions
Exception | Condition |
---|---|
ArgumentException | This GUID is invalid in the given document. |