Multiple Revit Versions Support

structure1EKNKU
Enthusiast

Multiple Revit Versions Support

structure1EKNKU
Enthusiast
Enthusiast

Hello!

 

I am writing a plugin which is supposed to support Revit Versions since 2020. By now it supports 2023 version and works on .NET 4.8 which causes crashes on exiting Revit in older version. A simple change of .NET version to 4.7.2 blocks building the binaries because the RevitAPI*.dll files referenced as assemblies come from 2023 version and are not compatible with older .NET versions. I could get older RevitAPI*.dll files instead but I wanted to know what is the best way to handle this in such a way that if some feature of the plugin is doable in 2023 only it would work in 2023 but the older versions would just have it blocked instead of getting crashed. Of course separate codes for each version are not an option.

 

All the best

0 Likes
Reply
Accepted solutions (1)
484 Views
4 Replies
Replies (4)

ricaun
Advisor
Advisor
Accepted solution

Hello,

 

I use the Configuration approach to change the RevitApi.dll Reference and the Net Framework as well.
In the end, I have one dll for each Revit version.


And to manage the code I use a #if #endif to only compile with a specific Revit version.

 

Here is a video I did using the Jeremy Template: https://github.com/jeremytammik/VisualStudioRevitAddinWizard to create a project and convert it to work with Revit 2020, Revit 2021, Revit 2022, and Revit 2023.

 

 

 

Here is the project/solution: https://github.com/ricaun-io/RevitAddin.MultVersion

 

Forum similar reference: https://forums.autodesk.com/t5/revit-api-forum/multi-version-add-in-using-nuget/td-p/11805174

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes

ptranU2KHX
Advocate
Advocate

Hi @ricaun 

Thank you for your great video, it helps me with the multiple versions. 

Do you happen to know how to setup debugging? I am currently stuck with visual studio 2019 because it is telling me that the source is different. I cannot debug.

 

ptranU2KHX_0-1696843184785.png

 

0 Likes

ricaun
Advisor
Advisor

Usually is just add the Program in the Debug configuration and works...

Like: https://github.com/ricaun-io/RevitAddin.MultVersion/blob/26c77aa8e19fd180fd84253a28b9d9bc3fbbd645/Re...

 

Your are using Visuals Basic maybe is that, or maybe is the Visual Studio 2019...

 

You could try to create a C# plugin just to test if the Debug works, if not works probably if Visual Studio or if works probably something in VB language.

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes

ptranU2KHX
Advocate
Advocate

Thanks @ricaun 

I figured out the problem. I have to set the 'Generate debug info' from 'none' to 'full.

ptranU2KHX_0-1696908553570.png