- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm currently working on a Revit add-in where I need to update a parameter (specifically the "User Name" parameter) of a View after its associated Viewport is removed from a sheet.
Problem:
I have set up an updater that triggers when elements are deleted using Element.GetChangeTypeElementDeletion() in the UpdaterRegistry. However, when a Viewport is deleted (e.g., a view is removed from a sheet), the ElementId returned by the UpdaterData.GetDeletedElementIds() method no longer points to a valid Element. As a result, I'm unable to retrieve the ViewId or any other information related to the View that was associated with the deleted Viewport.
What I've Tried:
Using var deletedIds = data.GetDeletedElementIds();: This method captures the IDs of the deleted elements but since the ElementId refers to a Viewport that has already been deleted, it's not possible to access the ViewId or update any parameters of the View after deletion.
Sub-Transaction Rollback: I attempted to start a sub-transaction before the deletion, retrieve the ViewId, and then roll back the sub-transaction to "undo" the deletion temporarily. Unfortunately, this approach did not work as expected, as it failed to capture the ViewId in a usable state before the deletion was finalized.
Question:
Is there a reliable method or best practice for updating a View parameter after its associated Viewport has been deleted from a sheet? Specifically, how can I capture the necessary information (like the ViewId) before the deletion is finalized so that I can update the "User Name" parameter after the deletion?
I would greatly appreciate any guidance or examples from those who have dealt with similar scenarios. Thanks in advance for your help!
Solved! Go to Solution.