pythonexcelrevit-apirevitpythonshell

How to turn 'string' into 'BuiltInCategory' in Revit Python Shell when reading excel file


I am trying to import data from Excel to Revit Python Shell in order to verify if some parameters exist in the Revit file for selected categories of objects. But I am having some problems in the first 'for' loop (look into the first column of the excel sheet and get the categories). The first step to achieving what I wanted would be to get all the elements of the categories that I want to analyze. I've tried a lot of things, but I always end up in this error shown in the picture (got string instead of built-in category). I searched for a method to transform a string into builtincategories, but I did not find anything.

Does anyone know how to deal with it? Is there a way to transform a string into built-in category or is there another solution for this?

Thank you! picture - screenshot


Solution

  • This question is more a C# than a Revit API one. Search for 'c# enum string convert', which turns up, e.g., convert a string to an enum in C#. In this case:

    BuiltInCategory bic = BuiltInCategory.Parse( "some_string" );