IronPython transition to CPython, how?

Hello,

Even AI is not helping me how to make the transition to IronPython2 to CPython ?

f.e. with this code

import clr

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument


OUT = [i.Name for i in doc.Settings.Categories]

KR

Andreas

Can’t fix an error which you aren’t communicating… What is the warning?

2023-08-11_10h33_47
2023-08-11_10h33_42

@jacob.small ,

any change makes new errors…

KR

Andreas

And in the first example, if you call doc.Settings as the entire line, what do you get?

@jacob.small ,

i will get category by name… …the code is already a bit progressed


import clr

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument

# Get the built-in categories
categories = list(BuiltInCategory.GetValues())

# Filter categories based on valid categories
valid_categories = []
for category in categories:
    if Category.GetCategory(doc, category) is not None:
        valid_categories.append(category)

# Get the category names and IDs
category_info = [(Category.GetCategory(doc, category).Name, category) for category in valid_categories]

OUT = category_info

the second example is just like IronPython …

import clr

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument


OUT = [i.Id for i in doc.Settings.Categories]

KR

Andreas