-
-
Notifications
You must be signed in to change notification settings - Fork 335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: cpython 3.8.5 shows "<class 'int'>" instead of "<class 'BuiltInParameter'>" enum member of BuiltInParameter #2241
Comments
I just tested it on pyRevit 4.8.16 , cpython 3.8.5 - same issue there. |
a possible workaround is to go via forge_type_id - it is not pretty though: 🤔
from Autodesk.Revit.DB import BuiltInParameter as Bip
from Autodesk.Revit.DB import ForgeTypeId, ParameterUtils
doc = __revit__.ActiveUIDocument.Document
param = doc.ActiveView.GenLevel.GetParameter(ForgeTypeId(ParameterUtils.GetParameterTypeId(getattr(Bip, "LEVEL_IS_BUILDING_STORY")).TypeId))
# instead of just:
# param = doc.ActiveView.GenLevel.get_Parameter(Bip.LEVEL_IS_BUILDING_STORY) but already the next step:
print(35*"-")
print("bic: forge_type_id_by_cat_name")
from Autodesk.Revit.DB import BuiltInCategory as Bic
from Autodesk.Revit.DB import Category
forge_type_id_by_cat_name = {}
for bic_cat in dir(Bic):
if bic_cat.startswith("OST_"):
bic_name = bic_cat.split("OST_")[-1]
bic = getattr(Bic, bic_cat)
if Category.IsBuiltInCategoryValid(bic):
ftid = Category.GetBuiltInCategoryTypeId(bic)
forge_type_id_by_cat_name[bic_name] = ftid.TypeId
# print(ftid.TypeId)
else:
pass
# print("skipped: ", bic_name)
print(f"found {} ftids".format(len(forge_type_id_by_cat_name)))
# for k, v in sorted(forge_type_id_by_cat_name.items()):
# print(k, v)
print(35*"-")
print("bip: forge_type_id_by_param_name")
from Autodesk.Revit.DB import BuiltInParameter as Bip
from Autodesk.Revit.DB import ForgeTypeId, ParameterUtils
forge_type_id_by_param_name = {}
skip_names = {
"INVALID",
"Overloads",
}
for bip_name in dir(Bip):
# print(bip_name)
if bip_name in skip_names:
continue
if bip_name.endswith("__"):
continue
bip = getattr(Bip, bip_name)
if "method" in str(bip) or "function" in str(bip):
continue
ftid = ParameterUtils.GetParameterTypeId(bip).TypeId
# print(bip_name, ftid)
forge_type_id_by_param_name[bip_name] = ftid
print("found {} ftids:".format(len(forge_type_id_by_param_name)))
# for k, v in sorted(forge_type_id_by_param_name.items()):
# print(k, v) so ideally there could be a fix with which we could access enums in pyRevit cpython the same way as in ironpython. 🤔 |
Hi @ay-ex, sorry for the delay in the response. This is a known bug of the version of pythonnet currently used by pyrevit. It was solved in version 3.0. |
hi @sanzoghenzo , |
Hi @ay-ex, The WIP installer has the updated version of pythonnet, can you try it to see if the problem persists? |
@sanzoghenzo thank you so much for the notification! 🙂 |
✈ Pre-Flight checks
🐞 Describe the bug
When running these (apart from python3 shebang identical) snippets:
in ironpython:
and cpython
with pyrevit engines ironpython 3.4.0 and cpython 3.8.5 I get different type results:
<class 'BuiltInParameter'>
(as expected)<class 'int'>
(not as expected)this prevents me from using
level.get_Parameter(Bip.LEVEL_IS_BUILDING_STORY)
to access ui-language-agnostic parameter values for built-in-parameters.
⌨ Error/Debug Message
♻️ To Reproduce
⏲️ Expected behavior
receiving
BuiltInParameter
type for both python interpreter versions.🖥️ Hardware and Software Setup (please complete the following information)
Additional context
there is a discussion on the forum describing the same problem:
https://discourse.pyrevitlabs.io/t/getting-parameters-of-element-in-cpython/3011
so far there is no solution mentioned there.
The text was updated successfully, but these errors were encountered: