Reputation: 23
I'm just trying to find a way to access the name property of an Area element inside Revit Python Shell, tried looking on Jeremy Tammik's amazingly informative blog, tried AUGI, Revit API docs, been looking for 2 days now...
Tried accessing via a bunch of ways, FilteredElementsCollector(doc).OfCategory(BuiltInCategory.OST_Areas), tried by Area class, tried through AreaTag, every single time I get an error under every circumstance and it's driving me nuts, it seems like such a simple issue that I can't seem to grasp!
EDIT: Also tried by element id, through tags, through area schemes, nada, no go...
Can anyone please tell me how to access this property via RPS?
Upvotes: 1
Views: 247
Reputation: 3706
I would say two things:
areaObject.LookupParameter("Name")
areaObject.GetParameters("Name")
...are valid methods. Please notice how I used GetParameters()
NOT GetParameter()
. There are some drawbacks to using either one of the two. The lookup method will return FIRST parameter that matches the name which in many cases might be a different parameter for different elements. It's not very reliable.
GetParameters()
method will return them all if there are multiple so then you have to deal with a List<Parameter>
rather than a single object that you can extract your value from.
I would personally recommend to use areaObject.get_Parameter(BuiltInParameter.ROOM_NAME)
method to extract a Name value from Area object. The BuiltInParameter always points at the same parameter, and will reliably return just that one parameter. Here's a little more details about these methods:
http://www.revitapidocs.com/2018/4400b9f8-3787-0947-5113-2522ff5e5de2.htm
Upvotes: 1
Reputation: 13327
Maybe your issue is the same as this one ? :
Your_Area.Name # throws error
Element.Name.GetValue(Your_Area) # works great
Upvotes: 1
Reputation: 23
To answer my own question, I actually never thought of looking through the code of other Revit Python scripts... in this case of PyRevit, which is in my opinion far more eloquently written than RPS, raelly looking forward for their console work to be done!
Basically, I had mistakenly used GetParameter('parameter') instead of LookupParameter('parameter').
As I said, it was something stupidly simple that I just didn't understand.
If anyone has sufficient knowledge to coherently clarify this, please do answer!
Many thanks!
Upvotes: 1