Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When get access to property "Name" of ElementType, an AttributeError raised. #854

Closed
Alvislakewang opened this issue Mar 12, 2020 · 2 comments
Labels
Question This is a question and not an issue

Comments

@Alvislakewang
Copy link

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:

image

Desktop (please complete the following information):

  • OS: Win10
  • pyRevit Version [e.g. 22]
  • pyRevit Environment:

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>

@htlcnn
Copy link
Contributor

htlcnn commented Mar 12, 2020

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

@eirannejad
Copy link
Collaborator

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)

@eirannejad eirannejad added the Question This is a question and not an issue label Mar 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question This is a question and not an issue
Projects
None yet
Development

No branches or pull requests

3 participants