#RTCNA Wish 5: Delete (almost) all revisions

Scott sent a tweet about deleting all revisions from a project. The tricky part is that, just like how the UI grays out the Delete button when there is only one revision in the project, we can’t use the API to delete the last revision.
This code uses the Revit 2015 API because the Revision class is new to 2015.

public void DeleteRevisions()
    Document doc = this.ActiveUIDocument.Document;

    // get list of all revisions in the document
    ICollection<ElementId> elementIds = new FilteredElementCollector(doc)
    // Remove the first revision from the list
    // Revit must have one revision in the document, so we can't delete them all

    using (Transaction t = new Transaction(doc,"Delete Revisions"))

One thought on “#RTCNA Wish 5: Delete (almost) all revisions

  1. Awesome! Thank you, looks relatively straightforward! Now to try and find the customer at #RTCNA that asked me if it could be done!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s