AttributeError : type object 'BuiltInCategory' has no attribute Dynamo

Hello,
I developed a simple Python script for Dynamo/Revit, and it worked perfectly on my computer, as shown in the attached image.

However, when I copied the same routine to Dynamo on another computer, the following error message appeared:

For reference, here’s the code I used:

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

fc = BuiltInCategory.OST_Walls

allStructConnections = FilteredElementCollector(doc).OfCategory(fc)

elements = allStructConnections.ToElements()

OUT = elements

I’m not sure what caused the error, and it doesn’t seem to make sense, especially since the versions are identical: Revit 2023.1 and Dynamo 2.16, both on my computer and my colleague’s.

Has anyone encountered this issue before? Any ideas on how to resolve it?

Thanks in advance for your attention and help! :blush:
getElements.dyn (2.9 KB)

This looks like a conflict with another addin or library, maybe pyRevit?

1 Like

Hello, thank you for your response!

I also suspect that this might be a library conflict, as you mentioned. However, I can confirm that we are not using pyRevit in this case.

Could you please suggest what other libraries or addins might be causing this issue? Are there any known conflicts we should check for?

Once again, thank you for your time and assistance—I truly appreciate your support!

I don’t know

By curiosity, this code works ?

import clr
import System
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

#fc = BuiltInCategory.OST_Walls

key_, values_ = System.Enum.GetNames(BuiltInCategory), System.Enum.GetValues(BuiltInCategory)
fc = System.Enum.Parse(BuiltInCategory, "OST_Walls")

OUT = fc, key_, values_

Hello, thank you for providing the new code!

We applied the code as instructed, but unfortunately, it didn’t resolve the issue. Instead, we encountered the error shown in the image I attached in the post.

Do you have any other suggestions or ideas about what might be causing this problem?

Try using the IronPython3 engine from the package manager (be sure to get the right version for your Dynamo release)… Sadly enums in CPython are dicey between builds.

2 Likes

I can’t say for sure, but I think the CPython3 engine doesn’t initialize correctly, try describing similar code using DyanmoSandBox 2.16, if you get the same error you may have a conflict with other software (I personally had a conflict with 3DS Max, which also uses Python).

For the production part, use IronPython2 or 3 in the meantime.

Note: if you can, it would be a good idea to test the latest PythonNet3 engine (Dynamo3.4-Revit 2025.4) to confirm whether the bug has been fixed.

1 Like