Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Remove Revisions on Sheets

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
rhanzlick
4360 Views, 6 Replies

Remove Revisions on Sheets

I am writing an addin to edit revisions for many sheets simultaneously. I see in the API that revisions can be added to a particular sheet using the 'SetAdditionalRevisionIds' method. However, I don't see an obvious way to remove revisions currently on a sheet. (This is all assuming we are modifying revisions that were manually added and not controlled by any content on the sheet eg revision clouds.) Is there a way to remove revisions from a sheet in the API?

 

Any help would be much appreciated.

 

Thanks,

Ryan

6 REPLIES 6
Message 2 of 7
TripleM-Dev.net
in reply to: rhanzlick

Hi,

 

Use GetAdditionalRevisionIds  , these are the revisions not created by revisionclouds on the sheet or in any of the placed views.

 

From the returned collection remove the id's of the revisions that need removing.

Then set SetAdditionalRevisionIds  with the edited collection from above.

 

ps: GetAllRevisionIds will return ALL revisions, from Revision clouds and "Revision on sheet" checkboxes.

conclusion: GetAllRevisionIds - GetAdditionalRevisionIds = RevisionIds set by revisionclouds.

 

Note deleting (and adding) Revisionclouds only possible if the Issued state of the revision is off.

This is not needed for SetAdditionalRevisionId (like in UI).

 

- Michel

Message 3 of 7
rhanzlick
in reply to: rhanzlick

I thought I tried this method, and it made no changes (the revisions were set to 'Issued'). However, I must have done something wrong the first time, because when I reimplemented, it works great!

 

Thanks,

Ryan

Message 4 of 7
tc
Participant
in reply to: rhanzlick

Dear fellow coders,

 

This week I had to solve a similar problem. Another way to approach this matter is by using the FilteredElementCollector. Assuming everything related to all the revisions on a sheet will be deleted, you can break it down in steps. First delete all revision cloud tags, secondly delete the revision clouds and finally the revisions. Below you can see an example. To complete the routine I also added a bit of code to avoid conflicts with revisions that are already issued. Hopefully this will help somebody for future use.

 

 

Dim revs As New SortedList(Of String, Boolean)
Dim colRev As New FilteredElementCollector(doc)

For Each r As Revision In colRev.OfCategory(BuiltInCategory.OST_Revisions)
   revs.Add(r.UniqueId, r.Issued)

   r.Issued = False
Next

Dim colRevClTags As New FilteredElementCollector(doc, sheet.Id)
doc.Delete(colRevClTags.OfCategory(BuiltInCategory.OST_RevisionCloudTags).ToElementIds)

Dim colRevCl As New FilteredElementCollector(doc, sheet.Id)
doc.Delete(colRevCl.OfCategory(BuiltInCategory.OST_RevisionClouds).ToElementIds)

Dim colRevs As New FilteredElementCollector(doc, sheet.Id)
doc.Delete(colRevs.OfCategory(BuiltInCategory.OST_Revisions).ToElementIds)

For Each r In revs
   Dim rev As Revision = doc.GetElement(r.Key)

   rev.Issued = r.Value
Next

 

 

Kind regards,

Tim

Message 5 of 7
rhanzlick
in reply to: tc

Wow thanks for the solution, but yours goes above and beyond my initial question! I'll convert yours to C#, and try it out when I have some time available.

Message 6 of 7
tc
Participant
in reply to: rhanzlick

Little correction. I just edited the code fragment I posted yesterday. Recovering the issued state of a revision doesn't seem to work by using the element id. Using the stable unique id instead fixes the problem.

Cheers!
Message 7 of 7
jeremy_tammik
in reply to: tc

Dear Tim,

  

Thank you for sharing this very clear and effective direct approach.

  

I am a bit surprised. I would have expected each successive call to OfCategory to be added to all existing previous filters. Therefore, calling it twice with different categories ought to return zero elements, and thrice even more so. Every filtering call on a given collector narrows down the search criteria further. "You need to reinitialise a filtered element collector before reusing it. All the filters that you add to it are accumulated. If they are mutually exclusive, you will get zero results."

  

https://thebuildingcoder.typepad.com/blog/2019/11/design-automation-api-stacks-collectors-and-links....

  

So, I am surprised that you can reuse the one single collector in the way you show.

  

But hey, if it works, so much the better. 

  

Congratulations and best regards,

  

Jeremy

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report