I’ve encountered a very weird problem with CPython.
I have two buttons created with pyRevit, Button1 and Button2.
Both buttons access another module that reads data from Revit extensible storage, the difference is that Button1 has #! python3 at the beginning of script.py while Button2 doesn’t.
All these works perfectly fine in Revit 2022, but when I run Button1 in Revit 2020, it gives the error CPython Traceback: TypeError : No method matches given arguments for Get: (<class 'Autodesk.Revit.DB.ExtensibleStorage.Field'>, <class 'int'>) when running the following code:
if int(app.VersionNumber) >= 2021:
unit = UnitTypeId.Custom
else:
unit = DisplayUnitType.DUT_CUSTOM
distance = entity.Get[float](self.dist_field, unit)
if I remove the #! python3 at the start of script.py then this error won’t occur, but I need it for some other functions in Button1.
this post mentioned the same problem but didn’t have a solution…
Hi @asasasa,
Unfortunately this is a bug of the current pythonnet version used by pyrevit. We’re working on updating it and finally bring some love to the cpython part of pyrevit, and it will be available in the next major release (pyrevit 5).
We can’t still give an ETA on this, but we’re getting closer…
Yes, please.
Unfortunately CPython support was an half-baked feature that didn’t get the love it deserved.
The whole .NET8 transition is complicating things a bit, but we’re progressing bit by bit!
Stay tuned
Back to your error: are your sure that this worked on IronPython with that specific family instance?have you tried using elem.get_Geometry(impOptions) instead?
Yes, It works in IronPython. initially that code was working in IronPython just fine until I ruined everything. lol.
I actually tried get_Geometry but I, of course, forgot to change the square brackets to parentheses. Yeah, It seems to be working this way.
I’m definitely not an expert in programming but I find it fairly easier to use Python 3 compared to 2.7.7.
I will slow it down but will keep switching to CPython a bit more carefully. have lots of them on the way. Should I keep reporting the issues as I encounter them or should I just assume that you know them all already? if yes, then should I do it here or in GitHub?
Since the main culprit is an outdated version of the pythonnet library, it’s not worth reporting the current issues, the are likely already fixed with the new version that we’re trying to use.
And my reaction would be the always same: “please wait for pyRevit 5”
The latest WIP installer is shipped with an updated version of pythonnet and the 3.12 CPython engine, please try it to see if it works or there’s some other things to solve before a proper release!