Revit Events


#1

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


#2

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).


#3

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 ?


#4

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 :

This would be fairly easy to achieve in an revit addin that is an external application, using document change event:
http://www.revitapidocs.com/2015/988dd6cf-fcaa-85d2-622d-c50f13917a13.htm


Subscribing to Revit API events (.Net event) in Iron Python
#5

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

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