Turn 'string' into 'BuiltInCategory' - Reading Excel in Revit Python Shell

54 views
Skip to first unread message

taispma...@gmail.com

unread,
Jun 18, 2020, 10:02:23 AM6/18/20
to RevitPythonShell
Hi! 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.
The first step to achieve what I wanted would be to get all the elements of the categories that I want to analyse. I've tried a lot of things, but I always end up in this situation shown in the picture. I searched for a method to transform string into builtincategories, but I did not find anything.



Here is the excel file:

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

Thank you!

Ed Green

unread,
Jun 19, 2020, 2:42:38 AM6/19/20
to RevitPythonShell
Hello taispmagalhaes

To convert a string to a BuiltInCategory you could use the python function  getattr to get the object property using the property name as a string... like this:


This takes the string you give it (you can split your excel input at the . ') and returns the corresponding BuiltInCategory enum 

Hope that helps

Happy coding!
Ed
Message has been deleted

taispma...@gmail.com

unread,
Jun 19, 2020, 3:10:37 AM6/19/20
to RevitPythonShell
Thanks a lot, Ed! It solved the problem :)


Reply all
Reply to author
Forward
0 new messages