Revit API UI more interactive

Revit API UI more interactive

Anonymous
Not applicable
2,637 Views
5 Replies
Message 1 of 6

Revit API UI more interactive

Anonymous
Not applicable

Hello,

 

I am trying to develop an API that is more interactive with the user than the ones I've seen in the Developer's Guide. What I am looking for is the APIs that allow users to insert information (numbers), select options from drop-down lists (Fig. 1), and show charts and graphs (a good example is the Revit's Energy Analysis plugin, where we select many options, etc. (Fig. 2 and Fig. 3)). However, as far as I've seen, the API by itself doesn't have such potential.

 

Fig. 1Fig. 1Fig. 2Fig. 2Fig. 3Fig. 3

 

Do API developers use other tools? If yes, which ones? SDK (e.g. Modeless Dialog) or WPF? I've tried using WPF but I can't insert a Revit command inside a button of a Window.

 

Thank you very much!

Cheers

Ruben

0 Likes
2,638 Views
5 Replies
Replies (5)
Message 2 of 6

aignatovich
Advisor
Advisor

You are absolutely correct.

 

There is an external events framework in Revit API that is the only way to create modalless dialogues, which needs to access Revit API. The UI can be done via WPF or even Windows.Forms, you could use any UI frameworks you want.

 

There is an example, that is shipped with SDK: Samples\ModelessDialog\ModelessForm_ExternalEvent

You can also find some examples here: http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.28

Message 3 of 6

RPTHOMAS108
Mentor
Mentor

For what you describe I would investigate using WPF over Forms. You can always host Forms in WPF if you need to use Rdlc report viewer etc.

 

Developing in WPF will allow closer interaction with the Revit UI in terms of implementing IDockablePaneProvider as well as adding custom controls to the options page (although the options page thing is something I've never had to do).

 

There is a steep learning curve with WPF over forms because of its lookless nature but that is also what allows it to be the thing you want it to be over what someone else has defined a control should be. Xaml born in WPF can also be the basis of WinRT UIs, so learning WPF gives a footing in that also.

 

Still though it infuriates me that WPF has no NumericalUpDownControl.

 

0 Likes
Message 4 of 6

Anonymous
Not applicable

Thank you very much for your comments.

 

I've successfully used an external event in a WPF Window. However, I've done it by calling the external event in the main code (i.e. Main Code: IExternalCommand) through the:

 

EventRegisterHandler _exeventHander = new EventRegisterHandler();
 _exEvent = ExternalEvent.Create(_exeventHander);

 

This means that my code will always use this event, no? I want to call different events according to the button that I select in the window (WPF). Is there a way to do it or I can only have a single external event?

0 Likes
Message 5 of 6

aignatovich
Advisor
Advisor

I'm not sure, that I correctly understand your question, but if you want to use event handlers, you should register them somewhere where Revit expects it, e.g. in application OnStartup event handler and then you can raise it wherever you want, e.g. from modalless form or timer. There is nothing that prevents you from creating multiple event handlers or to have a static flag, enumerable, etc. that can be changed from your form and control the behavior of your event handler

Message 6 of 6

Anonymous
Not applicable

Thank you very much!

 

I just followed your advise and created more events and event handlers  in my main code. Then, in my xaml.cs I just had to call different events according to my needs.

 

My error was, even though I created more handlers, that I was always calling for the same event in the xaml.cs.

 

Cheers!

0 Likes