Add-In Manager, FormulaManager and Tiger Year

Exciting news around debugging and loading add-ins and adding formulas and scripting support to your own apps:

Open Source Add-In Manager

Add-in developers have been clamouring for ages for the Revit development team to open source the Add-In Manager; the corresponding Revit Idea Station wish list item was raised in 2018 and has gathered 49 votes, and the request was originally raised and discussed earlier still.

Chuong Ho now took action and asks for your support:

Hi, all Developers working with Revit API, it's time; we need to improve addin manager tool for a long time. Now I'm in the process of developing and maintaining it on open source basis with more features to support developers easier access to Revit API. All the programmers in the world can help to make this product better for developer. Currently developing in my free time so nothing is perfect right now. Link to project open source at:

github.com/chuongmep/RevitAddInManager

RevitAddInManager

Many thanks to Chuong Ho for this great initiative!

Comments on LinkedIn:

By the way, I have started to use the apply code changes method now as well. It works fine and I love it. Reminds me of the good all days with edit and continue, which worked just a smoothly back then.

FormulaManager and Scripting Support

Richard RPThomas108 Thomas points out the existence and shows how to use the FormulaManager class in the Revit API discussion forum thread on creating user extensible functionality:

Question: I am creating a program that allows me to quantify elements. I calculate column surface areas using different formulas for interior and exterior columns. During the modelling process, the user may want to create new definitions, e.g., for a central column, with its own formula get_area. How could I implement support for the end user to add such functionality?

Answer: Several useful suggestions were made using the powerful built-in .NET scripting functionality. Richard adds a pure Revit solution, saying:

You may find FormulaManager.Evaluate offers a more Revit centric approach. However, it seems to imply that a parameter element is required:

It evaluates formula using list of global or family parameters depends on document type.

This probably means you have to be in a family document to evaluate a family parameter and a project to evaluate a global one. I guess you could make it work via adding what you need in a temporary way if it is requiring a parameter of some kind, i.e., a global one in project (although you wouldn't be able to reference other parameter names in the formula string). Here is a simple example that works:

  Public Function Obj_220118a(commandData As ExternalCommandData, ByRef message As String, elements As ElementSet) As Result
    Dim app = commandData.Application
    Dim uidoc = commandData.Application.ActiveUIDocument
    Dim IntDoc = uidoc.Document
    Dim Formula As String = "(10*10)^0.5"
    Dim Formula0 As String = "Pi()"
    Dim Out As String = ""
    Using Tx As New Transaction(IntDoc, "XX")
      If Tx.Start Then
        Dim G As String = Guid.NewGuid.ToString
        Dim GP = GlobalParameter.Create(IntDoc, "RPT_" & G, SpecTypeId.Number)
        Out = FormulaManager.Evaluate(GP.Id, IntDoc, Formula0)
        Tx.RollBack()
      End If
    End Using
    TaskDialog.Show("Result", Out)
    Return Result.Succeeded
  End Function

Many thanks to Richard for pointing out and sharing this!

Happy New Year of the Tiger 虎

Before leaving, I wish you all a Happy Chinese New Year, the Year of the Tiger, beginning next Tuesday, February 1.

Year of the Tiger