We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

Archicad Python API
About automating tasks in Archicad using the Python API.
SOLVED!

Python - List of names of the built-in properties

dushyant
Enthusiast
Hello
Does any know how to fetch the list of all the available built-in properties like "General_ElementID" for 'Element ID' available in the Python API?

Thanks.
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
poco2013
Mentor
The Property name for ElenentID is: IdAndCategoies_ElementID Built-ins use a single name with the group first , then underline then name . User properties separate the group and property name which is why they require separate functions to recall.

You can get a list of all properties by using the function GetAllPropertyNames()
Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27

View solution in original post

11 REPLIES 11
Solution
poco2013
Mentor
The Property name for ElenentID is: IdAndCategoies_ElementID Built-ins use a single name with the group first , then underline then name . User properties separate the group and property name which is why they require separate functions to recall.

You can get a list of all properties by using the function GetAllPropertyNames()
Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27
dushyant
Enthusiast
Thanks. GetAllPropertyNames() lists all the 'BuiltIn' and even 'UserDefined' properties.

What did you mean by "User properties separate the group and property name which is why they require separate functions to recall." ?
poco2013
Mentor
There are separate functions to get the Property ID for the built-in properties vs custom user properties.
acu,GetUserDefinedPropertyId which takes a group name and property name

acu.GetBuiltinPropertId which takes only the property name.

OR

You could create separate property classes (PropertUserId) one for builtin and one for property custom. The difference types require different inputs. Then use the common function acc.GetPropertyId(PropertyUserId) for both.
Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27
dushyant
Enthusiast
Got it, thanks!
Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni
Hi Guys,

There are two different types of Properties in ARCHICAD: User-Defined and Built-In.

User-Defined Properties
The User-Defined Properties are the ones you see in the Property Manager Dialog. Users can modify the name of these Properties so you can access them by the name you see on the user interface. We call this localized name. The localized name contains two strings the Group Name and the Property Name (as seen in Property Manager Dialog) and it's unique. Note, there can be two User-Defined Properties in two separate Groups with the same Property Name.

Please note, these User-Defined Properties are belong to the current project and may be not available in other projects. So if you refer to any User-Defined Property in your Python script, then it may not work with some projects.

Built-In Properties
The Built-In Properties are the ones defined by ARCHICAD. The user can't modify the name of these Properties so you can access them by their internal name. We call this non-localized name. If you use properties with non-localized names your script will be independent of the language of the ARCHICAD user interface.

Note, the non-localized names of Built-In Properties won't be changed between ARCHICAD updates and versions. So if you refer to any Built-In Properties in your Python script, then your script should work with any projects and any ARCHICAD versions.

You can find all the available Built-In Properties and currently available User-Defined Properties with the GetAllPropertyNames command.

As Python API is based on the JSON API, I recommend you to read the documentation of the JSON API:
http://archicadapi.graphisoft.com/JSONInterfaceDocumentation/#Property_Information
dushyant
Enthusiast
Ok, thanks for the info!
Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni
Python script examples for listing property values:
  • By using GetBuiltInPropertyId and GetUserDefinedPropertyId utility functions to retrieve the identifiers of the properties:
    from archicad import ACConnection
    
    conn = ACConnection.connect()
    acc = conn.commands
    act = conn.types
    acu = conn.utilities
    
    zoneNumberPropertyId = acu.GetBuiltInPropertyId('Zone_ZoneNumber')
    elementIdPropertyId = acu.GetBuiltInPropertyId('General_ElementID')
    zonesTemperatureReqPropertyId = acu.GetUserDefinedPropertyId('ZONES', 'Temperature Requirement')
    propertyIds = [
    	zoneNumberPropertyId,
    	elementIdPropertyId,
    	zonesTemperatureReqPropertyId
    ]
    
    propertyValuesDictionary = acu.GetPropertyValuesDictionary(acc.GetAllElements(), propertyIds)
    for elementId, valuesDictionary in propertyValuesDictionary.items():
    	for propertyId, value in valuesDictionary.items():
    		print(f"{elementId} {propertyId} {value}")
  • By using GetPropertyIds command to batch retrieve the identifier of the properties:
    from archicad import ACConnection
    
    conn = ACConnection.connect()
    acc = conn.commands
    act = conn.types
    acu = conn.utilities
    
    propertyIds = acc.GetPropertyIds([
    	act.BuiltInPropertyUserId('Zone_ZoneNumber'),
    	act.BuiltInPropertyUserId('General_ElementID'),
    	act.UserDefinedPropertyUserId(['ZONES', 'Temperature Requirement']),
    ])
    
    propertyValuesDictionary = acu.GetPropertyValuesDictionary(acc.GetAllElements(), propertyIds)
    for elementId, valuesDictionary in propertyValuesDictionary.items():
    	for propertyId, value in valuesDictionary.items():
    		print(f"{elementId} {propertyId} {value}")
The result of the scripts above is exactly the same. But there is performance difference.
If you want to optimize your Python script for performance (run time), then you should minimize the executed commands, because each of them requires communication between ARCHICAD which has costs.
All utility functions (acu) execute one or more commands (acc) to help writing python scripts. Every GetBuiltInPropertyId and GetUserDefinedPropertyId utility functions call GetPropertyIds command once, so the first script above communicates with ARCHICAD more and runs slower (however it's not sensible in this case).
dushyant
Enthusiast
On trying both of the codes, I get this:
    print(f"{elementId.guid} {propertyId.guid} {value}")
AttributeError: 'ElementIdArrayItem' object has no attribute 'guid'
poco2013
Mentor
Would have to see how you named ElementIdArrayItem , but assuming it is elemenId (confusing naming) , a return for guid would be elementId.elementId.guid
Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27