Revit Events

Hi guys

Just I was wondering is it possible to make an event from dynamo ?(eq. If delete view give msg error…etc) . or only can be done through API.

Interested to hear you answer also @Konrad_K_Sobon

Thank you

Yes. Custom messages and UI interface is possible using python via the API. You can even call system messages in windows (useful in sandbox mode).

1 Like

This very nice I thought that can’t be done through dynamo, but again is it possible to link this msg with event, like if anybody delete a view in the revit model it will pop up this msg ?

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

To further expand on Gui’s reply, Dynamo can only listen to Revit events while the graph is executing and dynamo can only execute inside of Revit’s idle event.

Revit’s idle event is only triggered when no other interaction is happening and when it’s activated, Revit’s context is busy until whatever triggered the idle event has completed it course.

Therefore, even if you subscribe to an event during the graph’s execution, that event won’t be triggered by anything that is the result of the same graph.

6 Likes

Thank you guys

@Gui_Talarico and @Dimitar_Venkov I think I will go through the API EVENT creation, and thanks for the links it’s rly helpful

Yes, you can.

5 Likes

That’s Great, Thanks Alex for your efforts!