Check if Subscription Release is installed

By Augusto Goncalves (@augustomaia)

At the Developer Center you’ll find the Revit 2015 SDK for Subscription Release. Like in previous years, this update include some new features, and Jeremy Tammik discussed at his blog post.

Ok, but can use on my plugin? You may have a user that don’t have this installed (due many reasons). You may check if is available via version number, but can get complicated if the user has a newer Update Release without this Subscription Release.

Here is a quick & easy approach: check if the new method is indeed available on the API reference loaded on runtime via Reflection. Here is how:

public static class VersionHelper{  public static bool Has2015SubscriptionRelease  {    get    {      return typeof(Autodesk.Revit.DB.Workset).GetMethod("Create") != null;    }  }}

The Workset.Create method is only available with this Subscription Release.

Now you may 2 DLLs, one compiled for the RTM and another for the Subscription Release. For a Ribbon, try something like:

public class MyApp : IExternalApplication{  public Result OnStartup(UIControlledApplication a)  {     PushButtonData pbd = new PushButtonData("MY_CMD", "My command",      VersionHelper.Has2015SubscriptionRelease ? "2015_SubsRelease.dll" : "2015_RTM.dll",      "Namespace.ClassName");     RibbonPanel pnl = a.CreateRibbonPanel("Version test");    pnl.AddItem(pbd); // this button will point to the correct DLL     return Result.Succeeded;  }}

Comments

2 responses to “Check if Subscription Release is installed”

  1. Matt Taylor Avatar
    Matt Taylor

    Hi,
    Just had to work this out, so putting it here for the search engines to pick up:
    Dim method As MethodInfo = GetType(DB.Workset).GetMethod(“Create”)
    ‘do this via reflection as we want to be able to compile this for
    ‘use with non-R2 and R2 releases of Revit 2015.
    method.Invoke(Nothing, {doc, worksetName})
    Cheers,
    Matt

  2. I’d like to thank the author for writing such an insightful and informative blog post about installation process that is not just useful to the readers but also revealing.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading