Getting name of element type doesn't work in Iron python for Revit

1.2k views Asked by At

I am working in Iron python in pyRevit environment and my code is as follows:

element_types = \
        DB.FilteredElementCollector(doc)\
          .OfCategory(DB.BuiltInCategory.OST_Walls)\
          .WhereElementIsElementType()\ # getting family types not elements
          .ToElements()

for ele in element_types:
    print(ele.Name)

As per Revit API documentation this should work and probably works in C#. There ele.Name works both as setter and getter. But in Ironpython above code fails, returning an AttributeError: Name. But when i try ele.Name = "new_family_type_name" it works fine.

So my question is how to make ele.Name work to get the family type name.

2

There are 2 answers

1
Callum On BEST ANSWER

This is normally one of the earliest quirks that you come across with RPS - but not to worry, its an easy fix. Try:

for ele in element_Types:
     print Element.Name.__get__(ele)
0
StXh On

Please try this code

from rpw import db

collector = db.Collector(of_class='WallType')
element_types = collector.get_elements()    

for ele in element_types:
    print(ele.name)