Hello,
I am writing a script to list all types exist in the project for specific categories, but whenever I try to get access to the property Name of ElementType Object, an AttributeError will be raised.
Code is as follow:
fc = BuiltInCategory.OST_StructuralFoundation
types = FilteredElementCollector(doc).OfCategory(fc).WhereElementIsElementType().ToElements()
type_names = []
for _type in types:
t_name = _type.Name
type_names.append(t_name)
Error information:
Desktop (please complete the following information):
C:\Users\alvis>pyrevit env
==> Registered Clones (full git repos)
==> Registered Clones (deployed from archive/image)
master | Deploy: "basepublic" | Branch: "master" | Version: "4.7.4" | Path: "C:\Users\alvis\AppData\Roaming\pyRevit-Master"
==> Attachments
master | Product: "2018 First Customer Ship" | Engine: 277 | Path: "C:\Users\alvis\AppData\Roaming\pyRevit-Master" | Manifest: "C:\Users\alvis\AppData\Roaming\Autodesk\Revit\Addins\2018\pyRevit.addin"
master | Product: "2017 First Customer Ship" | Engine: 277 | Path: "C:\Users\alvis\AppData\Roaming\pyRevit-Master" | Manifest: "C:\Users\alvis\AppData\Roaming\Autodesk\Revit\Addins\2017\pyRevit.addin"
master | Product: "2016 First Customer Ship" | Engine: 277 | Path: "C:\Users\alvis\AppData\Roaming\pyRevit-Master" | Manifest: "C:\Users\alvis\AppData\Roaming\Autodesk\Revit\Addins\2016\pyRevit.addin"
==> Installed Extensions
==> Default Extension Search Path
C:\Users\alvis\AppData\Roaming\pyRevit\Extensions
==> Extension Search Paths
==> Extension Sources - Default
https://github.com/eirannejad/pyRevit/raw/master/extensions/extensions.json
==> Extension Sources - Additional
==> Installed Revits
2018 First Customer Ship | Version: 18.0.0.420 | Build: 20170223_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2018"
2017 First Customer Ship | Version: 17.0.416.0 | Build: 20160225_1515(x64) | Language: 1033 | Path: ""
2016 First Customer Ship | Version: 16.0.428.0 | Build: 20150220_1215(x64) | Language: 1033 | Path: "D:\revit 2016\Revit 2016"
==> Running Revit Instances
PID: 6560 | 2018 First Customer Ship | Version: 18.0.0.420 | Build: 20170223_1515(x64) | Language: 0 | Path: "C:\Program Files\Autodesk\Revit 2018"
==> User Environment
Microsoft Windows 10 [Version 10.0.17763]
Executing User: ALVIS\alvis
Active User: ALVIS\alvis
Admin Access: No
%APPDATA%: "C:\Users\alvis\AppData\Roaming"
Latest Installed .Net Framework: 4.8
Installed .Net Target Packs: v3.5 v4.0 v4.5 v4.5.1 v4.5.2 v4.6 v4.6.1 v4.X
Installed .Net-Core Target Packs: v2.1.100 v2.1.101 v2.1.4
pyRevit CLI 0.17.0.0
C:\Users\alvis>
https://apidocs.co/apps/revit/2020/1198805b-fdbf-54bf-64d3-90dbd01b4c5f.htm
ElementType.Name is Write-Only (it only has set in API docs). If you want to get its name, please get its Parameter TypeName's value
Ya that's one of the known issues with IronPython. It specifically happens on the Name property. Use the workaround shown below to read the value:
DB.ElementType.Name.GetValue(_type)
Most helpful comment
Ya that's one of the known issues with IronPython. It specifically happens on the
Nameproperty. Use the workaround shown below to read the value: