Revit addin UI which launches command(s) programming architecture

Revit addin UI which launches command(s) programming architecture

Anonymous
Not applicable
1,766 Views
3 Replies
Message 1 of 4

Revit addin UI which launches command(s) programming architecture

Anonymous
Not applicable

BACKGROUND:

 

I'm developing a Revit Addin (C#) which has:

1. User interface to show and browse external data

2. Button to update selected item's properties in the model

 

 

I have an addin skeleton that executes an external command from the ribbon. My command then opens a non-modal dialog and returns.

 

CHALLENGE:

 

My fellow Revit developers told me that nr.2. requires my Addin to stay in the IExternalCommand::Execute context to be able to call Revit API functions.

They said that easiest is to do a Modal UI in the Execute function and run the API calls from that "context".

 

 

I can't "do modal" if I need the user to browse both the Revit model view and browse the external data shown by my addin UI.

 

My first idea was to:

1. open the non-modal Addin UI

2. start an event pump in the Execute function

3. and exit the event loop when my Addin UI is closed

 

QUESTION(s):

 

- Am I shooting myself in the foot with this approach?

- What would be the recommended way to design the run-time architecture of such an addin?

- Would a better approach be to register two Addins; The UI Addin, and an additional External command and do like in the example "Revit 2017 Add-In Executing a Custom External Command"

https://forums.autodesk.com/t5/revit-api-forum/revit-2017-add-in-executing-a-custom-external-command...

0 Likes
Accepted solutions (1)
1,767 Views
3 Replies
Replies (3)
Message 2 of 4

aignatovich
Advisor
Advisor
Accepted solution

Hi!

 

Read about ExternalEvents framework, which allows you to execute Revit API function in valid context when you are dealing with modeless dialogs, multiple threads and others. Look at Samples\ModelessDialog\ModelessForm_ExternalEvent\CS in Revit SDK for appropriate example

Message 3 of 4

jeremytammik
Autodesk
Autodesk

Thank you Alexander for the good answer.

 

I fully agree.

 

Here is all you need to know on this topic:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.28

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 4 of 4

Anonymous
Not applicable

Thanks, I will definitely read up on this - plus running commands from a dockable ui panel, that could be my next version.

0 Likes