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

IronPython in Revit API C# Plugin

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
evan.dinelli
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.

3 REPLIES 3
Message 2 of 4
jeremytammik
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:

 

https://duckduckgo.com/?q=does+ironpython+require+python+installation

 

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

 

https://stackoverflow.com/questions/7997794/how-to-run-a-python-program-on-a-windows-server-without-...

 

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

 

https://ironpython-test.readthedocs.io/en/latest/faq/installed.html

 

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

 

https://stackoverflow.com/questions/18880490/can-ironpython-run-on-machine-that-it-does-not-installe...

 

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

 

Best regards,

 

Jeremy

 



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

Message 3 of 4
stever66
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
Anonymous
in reply to: evan.dinelli

Hi,

 

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.

 

Regards,

 

Juan

 

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

Post to forums  

Autodesk Customer Advisory Groups


Rail Community