Getting Started Once Again

Welcoming my new colleague Carol leads to a renewed look at getting started:

Access Permission to Load my First Add-In

I probably pointed beginners to the Revit API getting started material several thousand times already, and sincerely hope that it provides a couple of useful pointers for them.

Still, people keep running into problems anyway.

A colleague hit another unexpected obstacle last week:

Question: I dived into the Getting Started with Revit platform API, following the DevTV tutorial by Augusto Goncalves. None of my commands appear on the Revit UI > Add Ins > external commands.

Answer: One thing you ought to read is the introductory section of the Revit API developers guide. It tells you exactly what to do to install and launch your add-in. It is shocking if that information is not clear and does not work in the tutorial, though. Thank you for bringing it up!

Installing a Revit add-in is really simple, but people run into difficulties like you describe anyway.

There are only two relevant components:

These are the important steps:

That is really all.

There are thousands of places explaining it; they all say the same thing.

Good luck and lots of fun with the Revit API :-)

Response: I have not had any luck since yesterday about my add-in not appearing in the Revit external commands.

I have carefully structured my code correctly. The add-in manifest file is pointing to my project .dll file. My project class explicitly implements the IExternalCommand interface and fires up the Execute method just fine. I don't understand what the issue could be.

Update: I managed to debug my code. Kindly, ignore previous message.

The location of my manifest add-in file was locked. I guess that happened when my account was set up. The location needed permission to be accessed. This path:

I utilised the try and catch exception to see the issue.

Once I gave access permission, the add-in file is now visible; it worked!

Assembly Path and Buttons Missing

Another issue getting started was resolved by decompiling and analysing the add-in .NET assembly DLL using IL decompilers, "Failed to initialize the add_in_name because the assembly path_to_an_add_in_DLL_file does not exist" when launching Revit:

Question: I've exhausted every resource possible and can not figure out what the issue is. Button images won't show and I keep getting this message launching Revit when I try to use the command:

Failed to initialize the [add-in name] because the assembly [path to an add-in DLL file] does not exist

But I may have been trying to run before I learned to walk with this one. The only thing I'm not understanding is why the commands work fine in the addins but the buttons can't find them.

Answer: Maybe your add-in is trying to reference a .NET assembly DLL that cannot be found when Revit tries to load it. Looking at the list of namespaces that you reference in your source code using statements, I see nothing but standard Autodesk Revit, Microsoft and .NET assemblies listed. So, they should all be present and accessible. Are you using anything else elsewhere in your code that is not obvious from that list? You might be able to use tools like fuslogv to analyse your add-in dependencies during load time, as suggested in the note on exploring assembly reference DLL hell with Fuslogvw.

Resdponse: Looks like I'm getting some XAML Binding errors during debug.

Update: I got one of the buttons to work correctly after I put the full path for the assemblies:

Update 2: The IL decompiler did the trick! The full class name was pulling as a different name. Now I just have to figure out the button images and I'll be in a good spot to start on my own plugins.

Update 3: Just solved my image issue. I changed the resources to embed and used the full path to the resources. Seems to have done the trick.

My First Revit Plug-in Todo

The My First Revit Plug-in tutorial available from the Revit Developer Center needs an overhaul, as the Revit API discussion forum thread on Revit Add-ins Tutorial needs an update for version 2021.1 points out.

Our new team member Carol Gitonga is just getting started with the Revit API herself and will very kindly take a look at it.

Many thanks and a warm welcome to Carol!

Books on Python for Revit Dynamo

Discussing another area to get started in, Gulshan gulshannegi94 Negi updated the thread on books or other resources to learn Python for Revit Dynamo:

Best ones are:

For more best Python book recommendations, check out the 10 Best Python Books for Beginners & Advanced Programmers.

pyRevit Saves Insane Amounts of Time

Talking about Python and Dynamo in Revit, Nicolas Catellier highlights 10 amazing pyRevit features to save insane amounts of time. As always, one of the best aspects of this is that it is all open source, so you access to source code for all the functionality presented.

Newtonsoft Json.dll Version Conflict

Question: A developer reported problems with their Revit add-ins. They make no use of any web services or BIM 360. Still, they cause problems with BIM360 under certain circumstances:

Answer: Probably some DLL in the customer’s add-on conflicts with Revit’s.

Does it by any chance use Newtonsoft.Json.dll?

After some analysis, I can see that it does indeed.

The add-in uses Newtonsoft.Json.dll version 13.0.1, two major versions newer than the one shipped with Revit 2021, which is version 11.0.2.

Probably they will have to downgrade the DLL. That is easy, if the app doesn’t consume any features only available only in versions 12 or 13.

They also need to make sure not to explicitly load the DLL (and any other DLLs), e.g., using Assembly.LoadFromFile.

In another case, a third-party add-in used the same version of Newtonsoft as Revit but explicitly loaded the DLL; this caused similar issues to Revit core functionalities.

Yet another example of DLL hell resolved.

Lost in the World by Steve Cutts

To wrap up, a little non-programming topic: I liked the animated two-and-a-half-minute short film Are You Lost in the World Like Me? by Steve Cutts very much, leading me to check out several of his other animations.

Steve Cutts

Happy Twosday!

2/2/22