I have a class containing functionality that works with Revit, I need to bind to a button on a WPF form, an action that would launch a class that works with Revit. I am new to this, so I would like a detailed answer with a code example. I have already read many forums, but did not find the answer.
You cannot call Execute yourself. The Revit external command Execute method is an event handler defined by the IExternalCommand interface and implemented by your external command:
https://www.revitapidocs.com/2023/ad99887e-db50-bf8f-e4e6-2fb86082b5fb.htm
It is only called by Revit itself, not by your, your add-in, or any other client.
How to implement an external command is discussed and explained in full detail in the getting started material, the Revit developer guide hello world samples, the My First Revit Plug-In tutorial video, many other YouTube tutorial videos, and numerous other places. Why should it be repeated yet again?
https://thebuildingcoder.typepad.com/blog/about-the-author.html#2
Please note that Revit API can only be used within a valid Revit API context. ExternalEvent allows you to do just that.
You can find a detailed explanation of driving Revit from outside can be found here:
https://thebuildingcoder.typepad.com/blog/2015/12/external-event-and-10-year-forum-anniversary.html.
You can also find WPF tutorials with Revit on YouTube. Here are a few samples you can refer:
https://www.youtube.com/watch?v=vHsqxRAqQOg
https://www.youtube.com/watch?v=KHMwd4U_Lrs
Dear Roma,
If you have WPF form specifically modeless one and need to call Revit API on button click you can use ExternalEvent and raise it on button click. Progress bar example that I added today contains what you need I guess. Please find it in the link below:
https://forums.autodesk.com/t5/revit-api-forum/can-anyone-share-a-working-implementation-of-wpf-prog...
Cheers - Marek
Hi,
How did you manage to manipulate WPFs in the Macro Manager? Everytime I try it SharpDevelop crashes.
Regards,
Hi, I remember that it crashed after switching back to code view from design view. In my Revit 2023 design view doesn't work at all so problem solved 😀
I wouldn't go into writing more complexed xaml in macro manager but this example could be done without preview.
Okay, thanks.
Regards,
Can't find what you're looking for? Ask the community or share your knowledge.