Built in Post function to CALL my own IExternalCommand in my own WPF window

Built in Post function to CALL my own IExternalCommand in my own WPF window

jlpgy
Advocate Advocate
578 Views
2 Replies
Message 1 of 3

Built in Post function to CALL my own IExternalCommand in my own WPF window

jlpgy
Advocate
Advocate

Hi:

 

I want to trig some Revit transactions from my own WPF window or page.

But I as well want to take advantage of the Revit built-in External Command function. Because I can return success, failed or canceled signal back to Revit main process, and Revit can handle it by popping out a built-in dialog conaining error message and highlighting the error elements.

 

For example:

I click a button in my own WPF dialog. In the Click event handler, I'd like to call some method like "PostExternalCommand( IExternalCommand myOwnClassInstance) ". And inside this ExternalCommand.Execute(), I can do lots of different tasks as my wish.

The point is that I only have to wrap some codes in the same class, and reuse it both in my own WPF dialog, and in Revit RibbonTab.

Is there any idea?

 

thanks a lot!

单身狗;代码狗;健身狗;jolinpiggy@hotmail.com
0 Likes
Accepted solutions (1)
579 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Accepted solution

You want to investigate the IExternalEvent framework.  The idea is that you will (from your WPF click handler) tell Revit that you want it to run a function.  myExternalEventHander.Raise().   See the ModelessDialog sample in the SDK for an example of how this is done.

 

in terms of wanting to use task dialogs and return Autodesk.Revit.DB.Result, you can always return a "Result" enum from any of your own functions.  In the event handler, you are in a valid Revit execution context so you have access to Revit from there.

 

Message 3 of 3

jlpgy
Advocate
Advocate

Thanks.

单身狗;代码狗;健身狗;jolinpiggy@hotmail.com
0 Likes