<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Changing Zone name using Python in Archicad Python API</title>
    <link>https://community.graphisoft.com/t5/Archicad-Python-API/Changing-Zone-name-using-Python/m-p/332975#M679</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;first of all thanks for sharing&amp;nbsp;&lt;SPAN&gt;knowledge. Really useful for beginner like me.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I tried to run your Zone renaming code but I'm getting error:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;BR /&gt;File "C:\Users\user\Downloads\zone rename.py", line 28, in &amp;lt;module&amp;gt;&lt;BR /&gt;propstr = propval_list.propertyValues[0].propertyValue.value&lt;BR /&gt;AttributeError: 'list' object has no attribute 'propertyValues'&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What am i dioing wrong?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Using Archicad 24,&amp;nbsp; 6004 and Python 3.9.1. and&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Best regards,&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Tom&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 22 Mar 2022 10:45:10 GMT</pubDate>
    <dc:creator>tom404</dc:creator>
    <dc:date>2022-03-22T10:45:10Z</dc:date>
    <item>
      <title>Changing Zone name using Python</title>
      <link>https://community.graphisoft.com/t5/Archicad-Python-API/Changing-Zone-name-using-Python/m-p/267090#M676</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;Is there a way to to change the Zone name using Python?&lt;BR /&gt;&lt;BR /&gt;I have seen that Zone number can be changed.&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;/DIV&gt;</description>
      <pubDate>Wed, 15 Sep 2021 07:55:37 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-Python-API/Changing-Zone-name-using-Python/m-p/267090#M676</guid>
      <dc:creator>Ady84a</dc:creator>
      <dc:date>2021-09-15T07:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Zone name using Python</title>
      <link>https://community.graphisoft.com/t5/Archicad-Python-API/Changing-Zone-name-using-Python/m-p/267091#M677</link>
      <description>Yes, this is possible.&lt;BR /&gt;
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).&lt;BR /&gt;

&lt;PRE&gt;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&lt;I&gt;.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])&lt;/I&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 01 Aug 2020 12:28:08 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-Python-API/Changing-Zone-name-using-Python/m-p/267091#M677</guid>
      <dc:creator>runxel</dc:creator>
      <dc:date>2020-08-01T12:28:08Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Zone name using Python</title>
      <link>https://community.graphisoft.com/t5/Archicad-Python-API/Changing-Zone-name-using-Python/m-p/267092#M678</link>
      <description>Thank you for your support!</description>
      <pubDate>Sat, 01 Aug 2020 12:55:09 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-Python-API/Changing-Zone-name-using-Python/m-p/267092#M678</guid>
      <dc:creator>Ady84a</dc:creator>
      <dc:date>2020-08-01T12:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Zone name using Python</title>
      <link>https://community.graphisoft.com/t5/Archicad-Python-API/Changing-Zone-name-using-Python/m-p/332975#M679</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;first of all thanks for sharing&amp;nbsp;&lt;SPAN&gt;knowledge. Really useful for beginner like me.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I tried to run your Zone renaming code but I'm getting error:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;BR /&gt;File "C:\Users\user\Downloads\zone rename.py", line 28, in &amp;lt;module&amp;gt;&lt;BR /&gt;propstr = propval_list.propertyValues[0].propertyValue.value&lt;BR /&gt;AttributeError: 'list' object has no attribute 'propertyValues'&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What am i dioing wrong?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Using Archicad 24,&amp;nbsp; 6004 and Python 3.9.1. and&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Best regards,&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Tom&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 10:45:10 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-Python-API/Changing-Zone-name-using-Python/m-p/332975#M679</guid>
      <dc:creator>tom404</dc:creator>
      <dc:date>2022-03-22T10:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Zone name using Python</title>
      <link>https://community.graphisoft.com/t5/Archicad-Python-API/Changing-Zone-name-using-Python/m-p/359681#M680</link>
      <description>&lt;P&gt;Hello runxel,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking for a script, how can I replace zone number actually through a custom property, could you maybe help?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 16:10:15 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-Python-API/Changing-Zone-name-using-Python/m-p/359681#M680</guid>
      <dc:creator>Daniel Pataki</dc:creator>
      <dc:date>2022-10-24T16:10:15Z</dc:date>
    </item>
  </channel>
</rss>

