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
Solved! Go to Solution.
Solved by TripleM-Dev.net. Go to Solution.
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
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
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
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.
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."
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
Can't find what you're looking for? Ask the community or share your knowledge.