Python Versions

Python Versions

michellem
Advocate Advocate
4,232 Views
5 Replies
Message 1 of 6

Python Versions

michellem
Advocate
Advocate

Hello;

 

I am trying to get straight the various flavors and versions of Python used with the various programming tools available in Revit. The more I plug away at this the more I get tripped up on version/flavor gotchas.

 

First I notice that Revit 2019/2020 ships with a macro IDE called SharpDevelop with the option of creating modules in Python. Does anyone know what version and flavor of Python is being used? (Cpython? IronPython? Python? Ver 2? Ver 3?) Does it vary with the Revit version? A link to a table would be great.

 

Next, Revit also ships with Dynamo and Dynamo has Python nodes. Nears as I can tell, Dynamo for Revit 2019 and later uses Cpython with special, Dynamo only, modules. (For example, Revit Services is one such module.) I think these modules would not be available to the Python used in the macro IDE. Are all of these statements, correct?

 

Sincerely;

Michelle

 

PS: Though this might be the wrong forum for this, but if anyone has any help on Python versions in Revit Python Shell and PyRevit, I would sure be grateful.

 

0 Likes
Accepted solutions (3)
4,233 Views
5 Replies
Replies (5)
Message 2 of 6

moturi.magati.george
Alumni
Alumni
Accepted solution

Hi @michellem,

 

SharpDevelop is an open source IDE integrated into Revit and it is out of support.

https://en.wikipedia.org/wiki/SharpDevelop

 

You can use multiple opensource python frameworks to write Revit Add-ins but they must support .NET. i.e RevitPythonShell, IronPython, Dynamo e.t.c

 

 

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

george1985
Collaborator
Collaborator
Accepted solution

Revit's Macros use IronPython 2.7.
Dynamo for Revit <=2020 uses IronPython 2.7.
Dynamo for Revit 2021, 2022 uses CPython 3 and IronPython 2.7.
Since Revit 2023, Dynamo by default uses only CPython 3. While it is still possible to additionally install IronPython 2.7.

Message 4 of 6

michellem
Advocate
Advocate

Hello George;

 

Thankyou for the tabulation.

 

For Revit 2021 & 2022 in Dynamo, does one have to do something - add a line of code, set a switch - to select between IronPython and CPython? Or does Dynamo automatically recognize the syntax of both flavors of Python? (For example, what happens if I cut/paste some IronPython code into a Dynamo Python node? Will it work? Or do I have modify it to run?)

 

Michelle

 

 

0 Likes
Message 5 of 6

george1985
Collaborator
Collaborator
Accepted solution

Hi @michellem ,
When you open Dynamo Python node, in the bottom part, there is button to chose the Python engine (IronPython or CPython).
If you've chose CPython for example, but your code is using IronPython syntax, and error will be raised that something is wrong (not that you chose the wrong engine).

Message 6 of 6

michellem
Advocate
Advocate

So you have to choose. Good to know as I tend to try something out in Revit Python Shell and then cut/paste into a Dynamo Python node.

 

Thanks much.

Michelle

 

0 Likes