Changing Zone name using Python

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2020-08-01
11:26 AM
- last edited on
‎2021-09-15
09:55 AM
by
Noemi Balogh
Is there a way to to change the Zone name using Python?
I have seen that Zone number can be changed.
Creating a new custom property and considering it as Zone name, doesn't solve our Problem. We need to change the actual Zone name in the Zone stamp.
Best regards,
- Labels:
-
Automation (Python or JSON)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2020-08-01 02:28 PM
Have a look at the code below. It's not that hard, once one understands that there are some shenanigans to come over (resulting from the use of heavily custom classes and types on the Python package side).
from archicad import ACConnection conn = ACConnection.connect() assert conn acc = conn.commands act = conn.types acu = conn.utilities # get all zones, assign to `elements` elements = acc.GetElementsByType('Zone') # prop now holds the GUID of the requested property prop = acu.GetBuiltInPropertyId('Zone_ZoneName') # returns a list of all the property values of the elements in question propval_list = acc.GetPropertyValuesOfElements(elements, [prop]) # replace all occurrences of the first string with the second one # (this is just a very basic example, of course you could do # much more sophisticated versions) zonename_to_replace = "Wohnen" zonename_new = "Main Room" for i, elem in enumerate(elements): # propstr holds the actual string of the current zone name propstr = propval_list.propertyValues[0].propertyValue.value # check if we got a match if propstr == zonename_to_replace: # if so, construct a new prop value new_val = act.ElementPropertyValue( elem.elementId, prop, act.NormalStringPropertyValue(zonename_new)) # set the zone name acc.SetPropertyValuesOfElements([new_val])
POSIWID – The Purpose Of a System Is What It Does /// «Furthermore, I consider that Carth... yearly releases must be destroyed»

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2020-08-01 02:55 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2022-03-22 11:45 AM
Hi,
first of all thanks for sharing knowledge. Really useful for beginner like me.
I tried to run your Zone renaming code but I'm getting error:
Traceback (most recent call last):
File "C:\Users\user\Downloads\zone rename.py", line 28, in <module>
propstr = propval_list.propertyValues[0].propertyValue.value
AttributeError: 'list' object has no attribute 'propertyValues'
What am i dioing wrong?
Using Archicad 24, 6004 and Python 3.9.1. and
Best regards,
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2022-10-24 06:10 PM
Hello runxel,
I am looking for a script, how can I replace zone number actually through a custom property, could you maybe help?
https://www.a-null.com/