User mep calculation for revit 2022

User mep calculation for revit 2022

josinaldo.santana32123
Participant Participant
425 Views
5 Replies
Message 1 of 6

User mep calculation for revit 2022

josinaldo.santana32123
Participant
Participant

I recently find an example of UserMepCalculation to add an user calculation of friction loss and flow convertion in the mechanical settings. The problem is: it was made for revit 2014 and the api changed a bit. I changed the methods and got zero errors in visual studio, but when i compile the project into dll files and put the addin file in the correct folder (C:\Program Files\Autodesk\Revit 2022\AddIns\MEPCalculation), nothing happens in revit. I am missing something?

The source code I changed is in UserMepCalculation2022. Thanks @jeremytammik for providing the example.

0 Likes
Accepted solutions (1)
426 Views
5 Replies
Replies (5)
Message 2 of 6

moturi.magati.george
Autodesk
Autodesk
Accepted solution

Hi @josinaldo.santana32123,

 

Kindly note that your addin path is wrong. Revit uses the following paths i.e.
Under Windows 10 - C:\ProgramData\Autodesk\Revit\Addins\20xx\ (The ProgramData folder is hidden by default) or C:\Users\%USERNAME%\AppData\Roaming\Autodesk\Revit\Addins\20xx\ (The AppData folder is hidden by default)

For more information, read about my first plugin here:
https://www.autodesk.com/support/technical/article/caas/tsarticles/ts/7JiiE4UoWHaTjxzuF754mL.html

  Moturi George,     Developer Advocacy and Support,  ADN Open
Message 3 of 6

josinaldo.santana32123
Participant
Participant

oh! I thought my external service had to be in the same folder as the built-in service calculation (now I see that this doesn't make sense). The add-in load is working now. I get another error, but I'm going to raise another topic. Thanks for your reply @moturi.magati.george ! 

0 Likes
Message 4 of 6

tamsann
Enthusiast
Enthusiast

Hello everyone

 

@josinaldo.santana32123 Hello, I am researching User MEP calculation, and when I tried to run the program, I encountered some errors:

 

  1. Error: "FormatUtils doesn't exist in the current context."
  2. Error: "CS1061 'Selection' does not contain a definition for 'Elements' and no accessible extension method 'Elements' accepting a first argument of type 'Selection' could be found (are you missing a using directive or an assembly reference?)"

 Could you with experience in fixing these errors please help me? I'm new to this and would greatly appreciate your assistance.1.jpg2.jpg

Message 5 of 6

josinaldo.santana32123
Participant
Participant

Hello! 

Some methods are deprecated in this Revit API version. FormatUtils was replaced by UnitFormatUtils (please note that this method now uses the ForgeTypeID). 

josinaldosantana32123_0-1687879490690.png

Another method deprecated was the UIDocument.Selection.Element. The selection class doesnt have the method Element anymore. You can use another method like ElementId and then get the element by his elementID.

You can have more information in Revitapidocs to review the methods and thebuildingcoder blog to understand how to use the ForgeTypeID.

 

Message 6 of 6

tamsann
Enthusiast
Enthusiast

Thank you very much for your help. 

0 Likes