Connecting External WPF Application to my Revit API Project

Connecting External WPF Application to my Revit API Project

ali_safieddineSNTCU
Explorer Explorer
710 Views
3 Replies
Message 1 of 4

Connecting External WPF Application to my Revit API Project

ali_safieddineSNTCU
Explorer
Explorer

Hello,

 

Before diving into details. My situation is that I have a WPF Application (.NET 6.0) and I want to connect it to my Revit API Addin (.NET Framework 4.8) noting that the 2 projects are in the same solution. The first error I get is that the 2 frameworks are not compatible! So what is the solution for that? 
My second question: Is this the best approach? I can see that separating the project is better for collaboration and provides more options. But is it the best practice or the WPF has to be inside the Revit API project? 

 

 

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

ricaun
Advisor
Advisor
Accepted solution

@ali_safieddineSNTCU wrote:

Before diving into details. My situation is that I have a WPF Application (.NET 6.0) and I want to connect it to my Revit API Addin (.NET Framework 4.8) noting that the 2 projects are in the same solution. The first error I get is that the 2 frameworks are not compatible! So what is the solution for that? 


That's tricky, why do you have a WPF Application (.NET 6.0), Is there some specific reason?
If is possible to change the project to .NET Framework 4.8 would be easier and the project needs to be a Library instead of the WPF application. You could build to support .NET Framework 4.8 and .NET 6.0 at the same time.

But if you cannot change, that is the Inter-Process Communication (IPC) route, using Pipes communication for example. The complexity goes to the roof, and most of the time it is not worth it.

 


My second question: Is this the best approach? I can see that separating the project is better for collaboration and provides more options. But is it the best practice or the WPF has to be inside the Revit API project?

Usualy is a good idea to separate the UI (Wpf) with the non UI stuff. Two separated project gonna depend, if you have a big project and you gonna reuse the UI outside Revit like a mock or something else, makes sense to separate in two projects.
If not, put everything in the same project, just organize the project with folder, like UI or Views.

 

The RevitLookup has a RevitLookup.UI project with all the UI and custom style, font, etc. It is a custom UI and a separate project is easier to maintain in that case. And a RevitLookup.UI.Demo is possible run a UI version outside Revit.

 

The RevitAddin.CommandLoader does not have a separate UI project, it only has a Wpf with a textbox and a button, and the style is the default.

 

I usually prefer the monolithic plugin approach, but in some projects, everything together gonna be a mess.

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

Message 3 of 4

ali_safieddineSNTCU
Explorer
Explorer

Thank you @ricaun , this is actually what I wanted to hear. The reason for WPF application is that it allows for some additional properties like creating an interface with multiple pages which I think is harder to do with WPF user control. If there is an example on creating pages using WPF (user control) it will be appreciated if you can share it. Thank you.

0 Likes
Message 4 of 4

ricaun
Advisor
Advisor

I'm not aware how the WPF application interface works with multiple pages. I know the Frame allow to load Page in a Window, and frame allow to navigate between pages.

 

I created this experiment project with a window with multiple pages.

 

PageNavigation.gif

The code only have one ViewModel and is shared between the Pages. The code is a little messy, everything is inside the PageView class.

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes