Migrating VSTA Macros to SharpDevelop

As you probably noticed, we held a very successful and exciting Revit API training course and DevLab recently in Melbourne.

More face-to-face hands-on trainings are planned, as you can see from the ADN Training Course Schedule, entering "Revit API" as the course name.

Revit API Hands-On Training in Munich

The next scheduled class that I will be conducting is taking place in Munich, Germany, on April 25-26 (register).

If you are interested in participating in a class, you will benefit enormously by preparing appropriately. The material we provide for that can also be used very well to learn the basics of the Revit API for yourself all on your own.

Meanwhile, here are some notes on the changes required to migrate our existing My First Revit Plugin (VB) code from Revit 2012 to 2013, reported by Saikat Bhattacharya:

Migrating VS 2010 Express Code

The only change was to update the following line of code using the obsolete Document.Element property:

  Element elem = pickedRef.Element;

This needs to be changed to call the Document.GetElement method:

  Element elem = doc.GetElement(pickedRef);

Migrating VSTA to SharpDevelop

There were a couple of steps in this migration:

1. Open the RVT files with embedded macros in SharpDevelop.

2. Change the .NET framework version to 4.0:

Set .NET Framework version

3. Remove existing references to the Revit API assembly DLLs and reference the Revit 2013 ones instead.

4. Delete the following line, since VSTA no longer exists in the Revit namespace:

Remove VSTA add-in id

5. Make the API changes in the code, essentially just the one line mentioned above for the VS Express change:

Update Element property to GetElement method

5. Update the description of the macro in the MacroManager dialogue.

I repeated the same set of steps for all the existing VSTA samples for C# and VB.NET for them to work with SharpDevelop.

Many thanks to Saikat for this report!