IronPython2 to CPython3 Coding issues

Hello,

I am trying to follow along with BIM Guru’s tutorial for placing floor finishes by room boundaries and apparently this did not translate well into Revit 2023 and the latest version of Dynamo. There is a line of code that is not reading right.

The error states: “ModuleNotFoundError : No module named ‘System.AppDomain’; ‘System’ is not a package [’ File"", line 12, in \n’]

This is what the code says;

1 # This is all from the Clockwork package (document.elementtypes)
2 # All credit for this part of the script goes to the author
3
4 import clr
5 clr.AddReference(‘RevitAPI’)
6 from Autodesk.Revit.DB import *
7 import Autodesk
8 clr.AddReference(‘RevitNodes’)
9 import Revit
10 clr.ImportExtensions(Revit.Elements)
11 import System.Reflection
12 import System.AppDomain
13
14 rAssembly = [x for x in System.AppDomain.CurrentDomain.GetAssemblies() if x.GetName().Name == ‘RevitAPI’][0]
15 rElement = [x for x in rAssembly.GetTypes() if x.Name == ‘Element’ and x.Namespace == ‘Autodesk.Revit.DB’][0]
16
17 etypes = [x for x in rAssembly.GetTypes() if x.IsClass and x.IsSubclassOf(rElement)]
18 enames = [t.Name for t in etypes]
19
20 OUT = [etypes, enames]

What does the error mean? Is it stating that AppDomain is no longer supported or allowed? How can I fix this code to work with Dynamo’s new coding?

These packages are built for IronPython, and for reasons like above I dont plan to use CPython3 anytime soon whilst I still support revit versions limited to IronPython.

I suggest installing the IronPython Dynamo package which will then enable these packages.