Make a utility function for version compatibility

Are you getting ready for Revit 2016 and now need to change dozens of hundreds of calls to “get_Parameter” like this?


And do you want your program to continue working with Revit 2013/2014?

If so, the way to go might be a utility function like this, which contains the conditional compilation needed to handle both old and new versions of the API.

public static Parameter getParam(Element e, string paramname)
#if RELEASE2013 || RELEASE2014
  return e.get_Parameter(paramname);
  return e.GetOrderedParameters().FirstOrDefault(q => q.Definition.Name == paramname);

Then your code to get a parameter becomes:

Utils.getParam(doc.ProjectInformation, paramName)

More on the topic of writing code to support multiple versions of Revit at: