Updating Plugins to Revit 2021

Anonymous

Updating Plugins to Revit 2021

Anonymous
Not applicable

Hello, 
I'm trying to update a revit plugin for Revit 2021.
The code of the plugin were designed for Revit 2019, but it also works in Revit 2020.

I Followed the guide described here: https://bit.ly/2za2t6i
and it worked for revit 2021 too. 

I've seen that revit 2021 API had several changes, one of then regarding the UnitUtils.ConvertFromInternalUnits() method. Now it uses a ForgeUnitID instead of a DisplayUnitType enum member.

My question is: Why the code that's been originally written in the 2019 version works seemlessly in Revit 2021 ?
Thank you!

0 Likes
Reply
Accepted solutions (1)
6,715 Views
9 Replies
Replies (9)

jeremytammik
Autodesk
Autodesk

Good question.

 

The answer is simple: the methods provided by the Revit API assemblies to serve the Revit API calls made by your add-in remain unchanged.

 

New methods have been added, for instance, the new unit API ones that you mention. However, you are not using them, so that makes no difference for your add-in.

 

Other methods may have been changed or even removed. However, luckily for you, you have not been using them, so that makes no difference for your add-in.

 

I hope this explains.

 

Best regards,

  

Jeremy

 



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

TripleM-Dev.net
Advisor
Advisor

Hi,

 

In the code for R2019 you haven't used any of the removed "obsolete" code in R2020/R2021.

Like rules for Filters they changed in R2019 and the old "style" was removed in R2020.

 

So if you used a command with these methods; the Addin wouldn't run or crash (if you usee the same assembly for R2020/R2021), also the .NET Framework version could be a issue.

 

See post (R2020, but also available for other versions): What's New in the Revit 2020 API

 

- Michel

Anonymous
Not applicable

I Actually have used a lot of methods that have been replaced in the 2021 version of the Revit API.

I use some of the methods of the UnitUtils class... some of then was replaced.

When visual studio compiles my code. Does it adapt, or recognize the old methods and somehow "translates" it to the new ones?

 

Thats the only thing i can think of.

Thanks

0 Likes

TripleM-Dev.net
Advisor
Advisor
Accepted solution

UnitUtils hasn't been removed in R2021, it will be gone in R2022 (if it follows the same route as always)

 

See Obsolete API removal 

Only Autodesk.Revit.DB.ImageImportOptions and methods relating to it have now been removed (and would return a error)

 

Once a function is replaced or obsolete (deprecated), it will be removed in the next Revit version.

For instance "ParameterFilterElement.GetRules" is marked as deprecated in studio for Revit 2019 and removed completely in Revit 2020.

 

- Michel

 

- Michel

jeremytammik
Autodesk
Autodesk

Many thanks to Michel for the detailed explanation!

 

To summarise and point out the gist of this:

 

This procedure gives you one year's time to update your code to remove all dependencies on deprecated API.

 

Ensure that your add-in compiles with zero warnings, and you will be ready to compile it for the next major release of Revit as well.

 

If your code generates warnings about using deprecated code now, it will no longer run unmodified in the next major release of Revit.

 



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

sofonias.s
Explorer
Explorer

this is a great article , thanks for letting me know that this is possible easily, yet i don't have a good programing knowledge , by any chance if you have updated the code for autosave plugin , i hope you can share it with me pls . all the free plugin stops at 2019. thanks @Anonymous 

0 Likes

sofonias.s
Explorer
Explorer
this is a great article , thanks for letting me know that this is possible easily, yet i don't have a good programing knowledge , by any chance if you have updated the code for autosave plugin , i hope you can share it with me pls . all the free plugin stops at 2019. thanks @
0 Likes

jeremy_tammik
Autodesk
Autodesk

You do not specify what you mean by 'all the free plugin', nor do you say exactly what you mean by 'autosave plugin'.

 

If it is one of the Revit add-ins that I share in GitHub repositories, I will gladly take a look at migrating it to Revit 2021.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes

sofonias.s
Explorer
Explorer
0 Likes