pyRevit vs CPython3

Hello all

In Revit I use pyrevit, in which I create my own tab. Since I have pyrevit installed, unfortunately no node in CPython3 works. If I uninstall pyrevit everything works as it should. All nodes in CPython3 reports the same error (see picture). Does anyone know how to solve the problem please?

I have the latest version of pyRevit and Revit is up to date. The same issue apear in Revit 2022 2023 and 2024.

Thank you
Lucie

And here is an example of a code in CPython3 with an error:

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
import Autodesk

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

names = []
cats = []
vag = []
pgs = []
pts = []
isvis = []
elems = []
guids = []
isinst = []
iterator = doc.ParameterBindings.ForwardIterator()
while iterator.MoveNext():
        vag.append(iterator.Key.VariesAcrossGroups)
        names.append(iterator.Key.Name)
        pgs.append(iterator.Key.ParameterGroup)
        pts.append(iterator.Key.GetType)
        isvis.append(iterator.Key.Visible)
        elem = doc.GetElement(iterator.Key.Id)
        elems.append(elem)
        if elem.GetType().ToString() == 'Autodesk.Revit.DB.SharedParameterElement':
                guids.append(elem.GuidValue)
        else: guids.append(None)
        if iterator.Current.GetType().ToString() == 'Autodesk.Revit.DB.InstanceBinding':
                isinst.append(True)
        else:
                isinst.append(False)
        thesecats = []
        for cat in iterator.Current.Categories:
                try:
                        thesecats.append(Revit.Elements.Category.ById(cat.Id.IntegerValue))
                except:
                        thesecats.append(None)
        cats.append(thesecats)
OUT = (names, cats, elems, isinst)

I have also this problem with ShowDialog with CPython3.
No problems in IronPython2.

Does anyone know how to solve this problem?

@Martin ,

A lot of users have this issue and Dynamo Team is aware of it, i don´t know when they will solve it.
I have the duct tape solution, just create a new line in the script, then it works…

you can bridge the gap with loading IronPython2 and 3 package to dynamo.

KR

Andreas

Helo Andreas,

thank you for your reply. Pleas what do you mean by creating a new line in the script?

Thanks.
Lucie

@Lucy_lastparametrics ,

edit your code randomly without do any harm… thats a Bug… and the solution is “contra-intutive”
you have to do it each time with opening… :wink:

thats the reason why i switched to PyRevit. Python is more clean to program, and you leave and breave outside the Autodesk enviroment.

2024-01-22_12h39_02

KR

Andreas

Thanks @andreasd811 for your video.

Does anyone know if there is any progress on this topic? We have many scripts we are currently using in pyrevit, and it is not a solution for me to go through all of them and change every Python node. Nevertheless I also ran into a situation when the solution drom Andreas didnt work.

Thank you
Lucy