Migrating a Revit add-in to a new release of the Revit API is generally very easy.
The API features slight changes from version to version.
Modifications are announced a year or two in advance, and signalled during compilation by deprecated API usage warnings.
If you clean up your code every year or two and remove all API usage that causes warning messages, you will normally have very little to do to migrate it later on.
If you run into any problems, just search the documentation on What's New in the Revit API; most modifications are listed there, including instructions on how to update the code to handle them:
- What's New in the Revit 2010 API
- What's New in the Revit 2011 API
- What's New in the Revit 2012 API
- What's New in the Revit 2013 API
- What's New in the Revit 2014 API
- What's New in the Revit 2015 API
- What's New in the Revit 2016 API
- What's New in the Revit 2017 API
- What's New in the Revit 2017.1 API
- What's New in the Revit 2018 API
- Revit 2018.1 API:
As an example, let's look at the migration of the PlaceInstances add-in implementing text file driven automatic placement of family instances from Revit 2014 to Revit 2018, prompted by two comments by Campbell and Renzo:
I'm trying to get this to work in Revit 2016; however,
FamilySymbolSetwas removed in 2016. Is there a workaround to get the plug in on this page to work without it? I can get the form to populate with families, but not show the types when I select one...
Could you find the solution?
Answer: Yes, this is easy.
FamilySymbolSet no longer exists; use a generic collection of element ids instead, in this case,
Family.Symbols no longer exists; use
I first performed a flat migration from the Revit 2014 API to Revit 2018, sinply updating the license year, .NET build target version and Revit API DLL references.
That causes the following errors and warnings:
------ Rebuild All started: Project: PlaceInstances, Configuration: Debug Any CPU ------ error CS0246: The type or namespace name 'FamilySymbolSet' could not be found (are you missing a using directive or an assembly reference?) error CS1061: 'Family' does not contain a definition for 'Symbols' and no extension method 'Symbols' accepting a first argument of type 'Family' could be found (are you missing a using directive or an assembly reference?) warning CS0162: Unreachable code detected ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
The warning message is intentional.
The Revit 2014 code causing the two errors looks like this:
FamilySymbolSet symbols = f.Symbols; // I have to convert the FamilySymbolSet to a // List, or the DataSource assignment will throw // an exception saying "Complex DataBinding // accepts as a data source either an IList or // an IListSource. List<FamilySymbol> symbols2 = new List<FamilySymbol>( symbols.Cast<FamilySymbol>() );
I converted it to compile for Revit 2018 like this:
ISet<ElementId> ids = f.GetFamilySymbolIds(); Document doc = f.Document; List<FamilySymbol> symbols2 = new List<FamilySymbol>( ids.Select<ElementId, FamilySymbol>( id => doc.GetElement( id ) as FamilySymbol ) );
You can check out the changes I made in the diff to the preceding version.
For the sake of completeness, here are the error lists before and after the fix.
I hope this helps.