Making a revit addin has been a goal of mine for some time. Yesterday I finally succeeded, complete with ridiculous names, images and tasks completed.

The addin is simple and essentially useless, it assigns walls of a certain type to a workset (Github).

Learning C#

I learned C# mostly through Autodesk's tutorial on the Revit API, found here. C# is different enough from python  that it initimiated me.

A few examples:

  • Declare variable types
  • Cast variables
  • Compile your code etc.


Those familiar with C# probably know all of these items, it was fun to learn on my end coming from python. This video guided me in making the ribbon found in the user interface of revit.

You can see in the code below, if you know what a for loop is, you can piece together what these lines are doing, there are just a lot more { } everywhere:

foreach (Workset workset in worksetList)
   if (workset.Name.Contains("Concrete"))
           ConcreteWalls = workset.Id.IntegerValue;
TaskDialog.Show("Revit", ConcreteWalls.ToString());
// note we have now identified the Concrete shearwall workset

Learning C# sharp was relatively quick. My mind remembered the pains of learning python, but most of the struggles with python were due to never learning about object oriented programming. Classes, objects and everything that went along with an object oriented programming were easy enough to map from python to C#.

Learning C# taught me an important skill, the use of debugger. Why I never used this while coding in Python I will never know. Debuggers allow you to not have to print variables out all the time and appear to have a lot more power that I have not yet unleashed. In the code example above, I was able to watch the debugger stepping through the foreach loop for each workset in the project, and if the workset contains "Concrete" it steps out of the for loop. I look forward to learning more about debugging in both C# and python.

As with any new skill or programming language, intimidation and coding tutorials are the obstacles to progress. Once I actually started coding, debugging, and yes, print screening still, making the addin started to click. 

A negative of C#

To debug the program you have to start and close revit all the time, this is super time consuming! The ability to quickly whip up a revit idea in dynamo and python is really unparalleled. Getting instant feed back on the items in a list of variable is definitely valuable. If you know of a way to get around revit having to fire up each time a change is made to the code, please let me know.

C# Moving forward

C# appears powerful, but will only be reserved for projects that warrant the slow development process. One that comes to my mind is the revit rebar bender. Knowing C# will help me alleviate the limitations that the rebar adaptive component faced. C# is also supported by the ETABs API and I believe you can even have your very own button in the UI of ETABs like Revit. More work in the future...

Revit C Sharp

Our Sidebar

You can put any information here you'd like.

  • Latest Comments
  • retug on RAM to RevitĀ® - R2R - (part 2) -

    Great ideas Celt.

    Mapping process done on beam ends would be a good alternate user option.

    With regards to the graphics, I agree, something to make deltas pop a little more visually would be nice.


  • Celt83 on RAM to RevitĀ® - R2R - (part 2) -

    Awesome stuff!

    Some possible additions that may be helpful.

    - allow the mapping process to be done against beam ends and not just grids.

    - you chose great colors for the beam maps, if you go one step further with the graphics and allow for a “multiply” blend mode all ...

  • retug on Diaphragm Slicer New and Improved -

    Hi Trenno, I just uploaded a new .dll file to github that has metric units included. Give it a whirl, let me know if you have any trouble on the install. I think it should be as easy as downloading the .dll file and adding the file path to the