Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

WinForms or WPF?

24 REPLIES 24
SOLVED
Reply
Message 1 of 25
Dale.Bartlett
5196 Views, 24 Replies

WinForms or WPF?

I am developing a new set of addins and don't know whether to launch into the brave new world of WPF or stick with trusty WinForms. Does anyone have some experiences and comments to share? I have a preference to hone new skills (WPF), but don't want to find myself in a dead-end. I am looking at ContentGeneratorWPF from the SDK for some guidance. Thanks again, Dale




______________
Yes, I'm Satoshi.
24 REPLIES 24
Message 21 of 25

@kraftwerk15 

 

There is one (major) issue though when i try to use WPF: as soon as you have something like a ShowDialog in your WPF form, it will lose focus on the WPF window and returns to revit instead of your form. The form will still be open, though the focus is back on revit and is no longer "blocked" as it should be. I doesnt seem to work either with the windowhandle that is been disused in an previous blog post from the buildingcoder (Jeremy).
I think this was the post: https://thebuildingcoder.typepad.com/blog/2010/06/revit-parent-window.html

Message 22 of 25

Dear Dante,

 

Note that the old way to access the Revit parent window was superseded in Revit 2019 by the introduction of the MainWindowHandle API:

 

https://thebuildingcoder.typepad.com/blog/2018/11/revit-window-handle-and-parenting-an-add-in-form.h...

 

Cheers,

 

Jeremy

 



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

Message 23 of 25

I must have missed that update. thanx.

 

So, just looking at that, i could call for Winforms:

 

 

IntPtr revit_window;
revit_window = commandData.Application.MainWindowHandle;
MyForm frm = new MyForm(commandData);
frm.ShowDialog(NativeWindow.FromHandle(revit_window));

 

 

But the thing is: WPF forms do not have an overload for ShowDialog. So it seems you can not point revit to be the native.

Consequence im facing now (also when using the sample code provided by @kraftwerk15  ) is that when you have some TaskDialog.Show() in your code, you will be pushed back to revit when you close the message instead of going back to your WPF-form, and it will even bring revit back in a full edit state.
This behavior is significantly different when your on WinForms, where it will go back to your form and keep revit in the frozen state until your showdialog is closed.

Message 24 of 25
MiguelGT17
in reply to: Dale.Bartlett

Sorry for bring this topic back again but I personally have managed to create this UI for revit add-ins using WPF xaml

MiguelGT17_0-1664687528151.png

Which is kind of fancy but If I want to go beyond that, to build something like this:

MiguelGT17_1-1664687586953.png

or this: 

MiguelGT17_2-1664687611020.png

I'm struggling generating dash lines, or any other curve lines with diferent font colors, moreover inserting images and playing around with its oppacity, and other visual effects, etc.

 

Does anyone has in mind any other tool that can reach those results? I've heard of .Net maui, although I've not figured out how to add dll reference to Maui projects.

 

All the best,

Miguel G.

Message 25 of 25
namunagetahun
in reply to: mastjaso

I was trying to figure out which one to go with for creating my first plugin. what you described makes sense. I think I am going to try WPF since I have some experience with XAML UI's.  Thanks for the detailed explanation.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report