Revit Events

Hi @Mohammad_Nawar

I could be wrong, but I don’t think you can do what you are asking in dynamo. It’s possible someone in here knows a way that can be achieved, but in the meantime, I will drop a few links below to support my thinking:

A dynamo graph is executed in the same way an external command runs:

Even if you do subscribe to an event to help you catch when a view is deleted (ie on document change) while the command is running, you would have to unsubscribe before the end of the command. That means as soon as graph is done executing, the events would no longer fire

See note about registering for events in external command :

Although events can be registered for External Commands as well as External Applications, it is not recommended unless the External Command registers and unregisters the event in the same external command

External command vs external application :
https://knowledge.autodesk.com/support/revit-products/downloads/caas/CloudHelp/cloudhelp/2016/ENU/Revit-API/files/GUID-411A9D2F-9748-46AC-9C2F-EA2D90DABCFD-htm.html

This would be fairly easy to achieve in an revit addin that is an external application, using document change event:

2 Likes