Coder Social home page Coder Social logo

Comments (4)

ay-ex avatar ay-ex commented on August 12, 2024 2

a possible workaround is to go via forge_type_id - it is not pretty though: 🤔

  • via direct access:
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: param.StorageType is your yet another enum that only returns int.

  • via creating dict as lookup table for BuiltInCategory:
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)
  • via creating dict as lookup table for BuiltInParameter:
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. 🤔

from pyrevit.

ay-ex avatar ay-ex commented on August 12, 2024

I just tested it on pyRevit 4.8.16 , cpython 3.8.5 - same issue there.

from pyrevit.

sanzoghenzo avatar sanzoghenzo commented on August 12, 2024

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.
We're trying to update it alongside the upgrade to the .net8 sdk to support revit 2025.
As this was not our project originally and we're not super c# experts, we're trying to do the best we can to reach this goal.
The upcoming pyrevit version 5 should fix this issue (no ETA yet, unfortunately).

from pyrevit.

ay-ex avatar ay-ex commented on August 12, 2024

hi @sanzoghenzo ,
no worries and thank you for the notification. 🙂
looking forward to pyRevit 5.

from pyrevit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.