Hi everybody,
I have a problem, I call ExternalEvent.Raise() but it doesn't execute immediately method "Execute" in ExternalEventHandler. In fact, RelayCommand complete, then "Execute" in ExternalEventHandler execute. Is there any way call Raise () and then immediately execute method "Execute"? Thank you.
Hi everybody,
I have a problem, I call ExternalEvent.Raise() but it doesn't execute immediately method "Execute" in ExternalEventHandler. In fact, RelayCommand complete, then "Execute" in ExternalEventHandler execute. Is there any way call Raise () and then immediately execute method "Execute"? Thank you.
Hi,
Please have a look on this link, some useful information and things to consider while useing external events.
https://thebuildingcoder.typepad.com/blog/2013/12/triggering-immediate-external-event-execute.html
Hope that helps
Hi,
Please have a look on this link, some useful information and things to consider while useing external events.
https://thebuildingcoder.typepad.com/blog/2013/12/triggering-immediate-external-event-execute.html
Hope that helps
Thank you for your help. I followed the following tutorial link
, but the result of "Execute" still did not execute after Raise (). Please, helps me.
Thank you for your help. I followed the following tutorial link
, but the result of "Execute" still did not execute after Raise (). Please, helps me.
You ask: Is there any way call Raise and then immediately execute method Execute?
I would say the answer is No.
Cheers,
Jeremy
You ask: Is there any way call Raise and then immediately execute method Execute?
I would say the answer is No.
Cheers,
Jeremy
I checked with a simple example like the image, the result is count = 0, not count = 1
I checked with a simple example like the image, the result is count = 0, not count = 1
Thank Jeremy,
So, do you have a way to use transactions outside of IExternalCommand, which works in order?
Thank Jeremy,
So, do you have a way to use transactions outside of IExternalCommand, which works in order?
Hi @jeremytammik and @NhuTruong_BeyCons
Here is how I solved it:
eventHandler.Execute(StaticClass.UIApplication)
and it works successfully.
@jeremytammik do you think this is a safe way to go?
Hi @jeremytammik and @NhuTruong_BeyCons
Here is how I solved it:
eventHandler.Execute(StaticClass.UIApplication)
and it works successfully.
@jeremytammik do you think this is a safe way to go?
That sounds fine to me. Congratulations on solving it!
That sounds fine to me. Congratulations on solving it!
So that means that I don't need this
https://thebuildingcoder.typepad.com/blog/2013/12/triggering-immediate-external-event-execute.html
complicated solution?
So that means that I don't need this
https://thebuildingcoder.typepad.com/blog/2013/12/triggering-immediate-external-event-execute.html
complicated solution?
If it works reliably for you under all circumstances, then not, obviously.
Please let us know, and I can add a note to that old post pointing out that there is a better way.
Thank you!
If it works reliably for you under all circumstances, then not, obviously.
Please let us know, and I can add a note to that old post pointing out that there is a better way.
Thank you!
Hi @jeremytammik and @NhuTruong_BeyCons
I realized that this is not a complete solution, because it only works with read-only events, but if you want to use a transaction in the event it will throw an exception that "Starting a transaction from an external application running outside of API context is not allowed", it only works with event.Raise().
But in fact, if you wanna do a read-only event, you don't need an IExternalEventHandler and call eventHandler.Execute() at all, you just need to save a reference to the UIApplication in a static field from the commandData when the first command to open the window is executed, and then you can use the UIApplication wherever in your code you want to read data from Revit.
Thanks
Hi @jeremytammik and @NhuTruong_BeyCons
I realized that this is not a complete solution, because it only works with read-only events, but if you want to use a transaction in the event it will throw an exception that "Starting a transaction from an external application running outside of API context is not allowed", it only works with event.Raise().
But in fact, if you wanna do a read-only event, you don't need an IExternalEventHandler and call eventHandler.Execute() at all, you just need to save a reference to the UIApplication in a static field from the commandData when the first command to open the window is executed, and then you can use the UIApplication wherever in your code you want to read data from Revit.
Thanks
You can also shoot yourself in the foot.
Making calls to the Revit API outside of a valid Revit API context can corrupt your data and crash Revit.
You cannot "use the UIApplication wherever in your code you want to read data from Revit".
You can only make calls from within a valid Revit API context:
http://thebuildingcoder.typepad.com/blog/2015/08/revit-api-context-and-form-creation-errors.html#2
You can also shoot yourself in the foot.
Making calls to the Revit API outside of a valid Revit API context can corrupt your data and crash Revit.
You cannot "use the UIApplication wherever in your code you want to read data from Revit".
You can only make calls from within a valid Revit API context:
http://thebuildingcoder.typepad.com/blog/2015/08/revit-api-context-and-form-creation-errors.html#2
Hi,I want to ask if you have solved this problem now?
Hi,I want to ask if you have solved this problem now?
Can't find what you're looking for? Ask the community or share your knowledge.