RevisionCombineWithNext Method

Combines the specified Revision with the next Revision.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntax
public static ISet<ElementId> CombineWithNext(
	Document document,
	ElementId revisionId
)

Parameters

document  Document
The Document containing the Revisions.
revisionId  ElementId
The Revision that should have its clouds and tags associated with the next Revision.

Return Value

ISetElementId
The ids of all RevisionClouds that were reassigned to the next Revision.
Exceptions
ExceptionCondition
ArgumentException revisionId is not a valid Revision. -or- This operation cannot be performed because revisionId is an issued Revision. -or- revisionId cannot be combined with the next Revision because either revisionId is the last Revision or the next Revision has already been issued.
ArgumentNullException A non-optional argument was null
Remarks
All RevisionClouds and tags associated with the specified Revision will be reassigned to the next Revision in the model and the specified Revision will be deleted from the model. The operation can only be performed if both the specified Revision and the next one are unissued.
Example
private bool CombineRevision(Document document, Revision revision)
{
    bool combined = false;
    // Can only combine two revisions if neither have been issued
    if (revision.Issued == false)
    {
        ElementId revisionId = revision.Id;
        Revision nextRevsion = GetNextRevision(document, revisionId);
        if (nextRevsion != null && nextRevsion.Issued == false)
        {
            ISet<ElementId> revisionCloudIds = Revision.CombineWithNext(document, revisionId);
            combined = true;
            int movedClouds = revisionCloudIds.Count;
            if (movedClouds > 0)
            {
                RevisionCloud cloud = document.GetElement(revisionCloudIds.ElementAt(0)) as RevisionCloud;
                if (cloud != null)
                {
                    string msg = string.Format("Revision {0} deleted and {1} revision clouds were added to Revsion {2}",
                        revisionId.ToString(), movedClouds, cloud.RevisionId.ToString());
                    TaskDialog.Show("Revision Combined", msg);
                }
            }
        }
    }

    return combined;
}

private Revision GetNextRevision(Document document, ElementId currentRevisionId)
{
    Revision nextRevision = null;
    IList<ElementId> revisionIds = Revision.GetAllRevisionIds(document);
    int currentRevisionIndex = -1;
    for (int n = 0; n < revisionIds.Count; n++)
    {
        if (revisionIds[n] == currentRevisionId)
        {
            currentRevisionIndex = n;
            break;
        }
    }

    // if the current revision id was found and is not the last index
    if (currentRevisionIndex >= 0 && currentRevisionIndex < revisionIds.Count - 1)
    {
        ElementId nextRevisionId = revisionIds[currentRevisionIndex + 1];
        nextRevision = document.GetElement(nextRevisionId) as Revision;
    }

    return nextRevision;
}
See Also