Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IronPython in Revit API C# Plugin

Message 1 of 4
2881 Views, 3 Replies

IronPython in Revit API C# Plugin

Is it possible to compile a Revit add-in with Python code for a user that does not have an install of Python using IronPython or alike?


In a Revit plugin written in C# I'd like to do data processing and machine learning, which seems best to be done in Python because of readily available packages such as Gensim, Tensorflow, FuzzyWuzzy, Pandas, etc. I don't want to assume or ask the end user to install Python to run my plugin, but would still like to use those Python packages. I got IronPython working on my machine with a Python install, but cannot run the same script on a machine without a Python install. Please let me know if any clarification would help.

Message 2 of 4
in reply to: evan.dinelli

Dear Evan,


Thank you for your query.


You will probably have to do some research on this yourself in other, non-Revit related forums.


I searched the Internet for "does ironpython require python installation" and found a lot of promising answers that turn up a surprising number of alternative approaches:


Portable Python provides a possibility to install Python without really installing Python:


This note in the IronPython documentation seems to indicate that IronPython itself does not require a Python installation:


If you just want to run your IronPython script on different machines without installing much, it is easy to distribute an IronPython app:


I hope this helps and look forward to hearing how you end up solving this.


Best regards,




Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 4
in reply to: evan.dinelli

You could try the built in Sharp Macro Editor.


It has not only C#, but also Python, Ruby, and Visual Basic.  And you can add references to libraries under the "Project" - "Add Reference" menu.  I assume that will add the required libraries to the compiled code.


Duplicating your code from one computer to another might require a little more work.



Message 4 of 4
in reply to: evan.dinelli



Be careful with IronPython, because it may not be compatible with the libraries you are mentioning. I had that problem in the past. That also apply to python nodes in Dynamo and python macros in Revit

For simple applications, the approach I follow is: I use Ironpython embedded in a .net Windows application to gather the input data and I pickle the info into a file. Then I have another  python app (either Python 2 or 3 depending on the case) that unpickles the data and performs the calculation, displays results, etc. If neccessary, I can pickle the results and unpickle them again in IronPython for processing inside the ,NET appilication, although I have not played too much with it.

Lastly, I use py2exe to encapsulate this python app and all the python related libraries into an exectutable file that can be included in the .net installation program. That eliminates the need for having the python installation and all the required packages in the clients' computers.






Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups

Rail Community