<?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: Customization Python Script - ZONE NUMBERING in Archicad Python API</title>
    <link>https://community.graphisoft.com/t5/Archicad-Python-API/Customization-Python-Script-ZONE-NUMBERING/m-p/366513#M280</link>
    <description>&lt;P&gt;Hey &lt;a href="https://community.graphisoft.com/t5/user/viewprofilepage/user-id/4323"&gt;@Daniel Pataki&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following will provide you with the necessary:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from Archicad import ACConnection

conn = ACConnection.connect()
assert conn

acc = conn.commands
act = conn.types
acu = conn.utilities

# get all zones (returns GUIDs)
elem_all_zones = acc.GetElementsByType('Zone')

# returns GUIDs of prop (Built-ins are non-localized)
prop_znumber = acu.GetBuiltInPropertyId('Zone_ZoneNumber')

# user properties are localized: 'Group', 'Prop Name'
# CHANGE THIS:
prop_pnumber = acu.GetUserDefinedPropertyId('Allgemeine Werte', 'Raumnummer')

propvallist_pnumber = [val.propertyValues[0].propertyValue.value for val in acc.GetPropertyValuesOfElements(elem_all_zones, [prop_pnumber])]

for i, elem in enumerate(elem_all_zones):
    new_zonenumber = act.ElementPropertyValue(
                elem.elementId, prop_znumber, act.NormalStringPropertyValue(propvallist_pnumber[i]))
    # write number back
    acc.SetPropertyValuesOfElements([new_zonenumber])&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 02 Jan 2023 21:43:45 GMT</pubDate>
    <dc:creator>runxel</dc:creator>
    <dc:date>2023-01-02T21:43:45Z</dc:date>
    <item>
      <title>Customization Python Script - ZONE NUMBERING</title>
      <link>https://community.graphisoft.com/t5/Archicad-Python-API/Customization-Python-Script-ZONE-NUMBERING/m-p/358420#M274</link>
      <description>&lt;P&gt;Hello Everybody,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to give a custom number for every Zone in my Project.&lt;/P&gt;&lt;P&gt;The result should be construct with the Storyname and the zone Number.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;XXXX&lt;/FONT&gt;-&lt;FONT color="#000080"&gt;XXX&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Storeyname-&lt;FONT color="#003366"&gt;Zone Number&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/30548iAF43FEB0393D2A5D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt; &lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/30547i49A30E2C8C8955A9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;How could we customize the Python-Script &amp;nbsp;to insert the Storey name in front of the Zone numbering?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from Archicad import ACConnection
from typing import List, Tuple, Iterable
from itertools import cycle

conn = ACConnection.connect()
assert conn

acc = conn.commands
act = conn.types
acu = conn.utilities

################################ CONFIGURATION #################################
propertyId = acu.GetBuiltInPropertyId('Zone_ZoneNumber')
propertyValueStringPrefix = ''
elements = acc.GetElementsByType('Zone')

ROW_GROUPING_LIMIT = 0.25
STORY_GROUPING_LIMIT = 1

def GeneratePropertyValueString(storyIndex: int, elemIndex: int) -&amp;gt; str:
    return f"{propertyValueStringPrefix}{storyIndex:1d}{elemIndex:02d}"
################################################################################


def generatePropertyValue(storyIndex: int, elemIndex: int) -&amp;gt; act.NormalStringPropertyValue:
    return act.NormalStringPropertyValue(GeneratePropertyValueString(storyIndex, elemIndex))


def createClusters(positions: Iterable[float], limit: float) -&amp;gt; List[Tuple[float, float]]:
    positions = sorted(positions)
    if len(positions) == 0:
        return []

    clusters = []
    posIter = iter(positions)
    firstPos = lastPos = next(posIter)

    for pos in posIter:
        if pos - lastPos &amp;lt;= limit:
            lastPos = pos
        else:
            clusters.append((firstPos, lastPos))
            firstPos = lastPos = pos

    clusters.append((firstPos, lastPos))
    return clusters


boundingBoxes = acc.Get3DBoundingBoxes(elements)
elementBoundingBoxes = list(zip(elements, boundingBoxes))
zClusters = createClusters((bb.boundingBox3D.zMin for bb in boundingBoxes), STORY_GROUPING_LIMIT)

storyIndex = 0
elemPropertyValues = []
for (zMin, zMax) in zClusters:
    elemIndex = 1
    elemsOnStory = [e for e in elementBoundingBoxes if zMin &amp;lt;= e[1].boundingBox3D.zMin &amp;lt;= zMax]
    yClusters = createClusters((e[1].boundingBox3D.yMin for e in elemsOnStory), ROW_GROUPING_LIMIT)

    for ((yMin, yMax), reverseOrder) in zip(yClusters, cycle([False, True])):
        elemsInRow = [e for e in elemsOnStory
                        if yMin &amp;lt;= e[1].boundingBox3D.yMin &amp;lt;= yMax]

        for (elem, bb) in sorted(elemsInRow, key=lambda e: e[1].boundingBox3D.xMin, reverse=reverseOrder):
            elemPropertyValues.append(act.ElementPropertyValue(
                elem.elementId, propertyId, generatePropertyValue(storyIndex, elemIndex)))
            elemIndex += 1
    storyIndex += 1

acc.SetPropertyValuesOfElements(elemPropertyValues)

# Print the result
newValues = acc.GetPropertyValuesOfElements(elements, [propertyId])
elemAndValuePairs = [(elements[i].elementId.guid, v.propertyValue.value) for i in range(len(newValues)) for v in newValues[i].propertyValues]
for elemAndValuePair in sorted(elemAndValuePairs, key=lambda p: p[1]):
    print(elemAndValuePair)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank in Advance for your Support&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 07:41:11 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-Python-API/Customization-Python-Script-ZONE-NUMBERING/m-p/358420#M274</guid>
      <dc:creator>Anarchiteckt</dc:creator>
      <dc:date>2022-10-11T07:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: Customization Python Script - ZONE NUMBERING</title>
      <link>https://community.graphisoft.com/t5/Archicad-Python-API/Customization-Python-Script-ZONE-NUMBERING/m-p/358519#M275</link>
      <description>&lt;P&gt;Hy,&lt;/P&gt;&lt;P&gt;With Python I don't know… but in GDL it's very easy.&lt;BR /&gt;Make a copy of the zone mark object and add these few lines at the beginning of the master script&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;n = REQUEST ("Home_story", "", index, story_name)
num_eta = STR ("%.0m", index)

ROOM_NUMBER = story_name + "."+ ROOM_NUMBER&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 12 Oct 2022 15:17:01 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-Python-API/Customization-Python-Script-ZONE-NUMBERING/m-p/358519#M275</guid>
      <dc:creator>Yves</dc:creator>
      <dc:date>2022-10-12T15:17:01Z</dc:date>
    </item>
    <item>
      <title>Re: Customization Python Script - ZONE NUMBERING</title>
      <link>https://community.graphisoft.com/t5/Archicad-Python-API/Customization-Python-Script-ZONE-NUMBERING/m-p/358594#M276</link>
      <description>&lt;P&gt;Hy Yves,&lt;BR /&gt;&lt;BR /&gt;Thank you for your solution. It's work very well!!!&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Capture d’écran 2022-10-13 à 11.47.33.png" style="width: 200px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/30586i1A44B01B52B78EC5/image-size/small?v=v2&amp;amp;px=200" role="button" title="Capture d’écran 2022-10-13 à 11.47.33.png" alt="Capture d’écran 2022-10-13 à 11.47.33.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After the&lt;STRONG&gt; changing the GDL code&lt;/STRONG&gt;, you can run the Python script and print the ROOM NUMBER&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Capture d’écran 2022-10-13 à 11.57.42.png" style="width: 176px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/30587i7E8E4043AE678355/image-size/small?v=v2&amp;amp;px=200" role="button" title="Capture d’écran 2022-10-13 à 11.57.42.png" alt="Capture d’écran 2022-10-13 à 11.57.42.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;----&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Gwenael Tripodi, Architect | BIM Manager&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AC 8.1-26&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MacOS Big Sur | 3,8 GHz i7 8Core | 24GB | AMD 5500 XT&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 10:01:28 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-Python-API/Customization-Python-Script-ZONE-NUMBERING/m-p/358594#M276</guid>
      <dc:creator>Anarchiteckt</dc:creator>
      <dc:date>2022-10-13T10:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: Customization Python Script - ZONE NUMBERING</title>
      <link>https://community.graphisoft.com/t5/Archicad-Python-API/Customization-Python-Script-ZONE-NUMBERING/m-p/358652#M277</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hey Yves,&lt;BR /&gt;&lt;BR /&gt;I just spoked with the User from the Model...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;He needs to "Print"&amp;nbsp;the the complete Information in Room number.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;With GDL, you can show the Information on the floor plan as a "prefix".&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture d’écran 2022-10-13 à 17.06.38.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/30613i0425F133406A7A07/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture d’écran 2022-10-13 à 17.06.38.png" alt="Capture d’écran 2022-10-13 à 17.06.38.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;Maybe&amp;nbsp;there are some&amp;nbsp;possibility to made it with Python....&lt;BR /&gt;We could create a User Property for the the Story name and print this User Property with a Built-in Property (Roomnummer) Together.&lt;BR /&gt;&lt;BR /&gt;But I have no idea what the Python code should look like....&lt;BR /&gt;Does anyone have any ideas?&lt;BR /&gt;&lt;BR /&gt;---&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Gwenael Tripodi, Architect | BIM Manager&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AC 8.1-26&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MacOS Big Sur | 3,8 GHz i7 8Core | 24GB | AMD 5500 XT&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 15:21:14 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-Python-API/Customization-Python-Script-ZONE-NUMBERING/m-p/358652#M277</guid>
      <dc:creator>Anarchiteckt</dc:creator>
      <dc:date>2022-10-13T15:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: Customization Python Script - ZONE NUMBERING</title>
      <link>https://community.graphisoft.com/t5/Archicad-Python-API/Customization-Python-Script-ZONE-NUMBERING/m-p/358947#M278</link>
      <description>&lt;P&gt;I believe that the GDL script might be the simpler approach if you could live with the above. But if you wanted to use Python? you would first have to create two custom properties, classified to zones( spaces).&lt;/P&gt;&lt;P&gt;1. An expression returning the Story Name for the zone&lt;/P&gt;&lt;P&gt;2. A custom property to receive the room name.&lt;/P&gt;&lt;P&gt;3. Then configure the zone label to display the custom property -- room name&lt;/P&gt;&lt;P&gt;The Python code would be as follows:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from Archicad import ACConnection
import Archicad
conn = ACConnection.connect()

assert conn

acc = conn.commands
act = conn.types
acu = conn.utilities
zoneNumberId = acu.GetBuiltInPropertyId('Zone_ZoneNumber') 
roomNameId = acu.GetUserDefinedPropertyId('Zone_Names','RoomName')
storyNameId = acu.GetUserDefinedPropertyId('Zone_Names','Story_Name')

zones = acc.GetElementsByType('Zone')
names =[]
for element in zones:
    number = acc.GetPropertyValuesOfElements([element],[zoneNumberId,storyNameId])
    name = (number[0].propertyValues[0].propertyValue.value,
    number[0].propertyValues[1].propertyValue.value)
    name = name[1]+'-'+name[0]
    names.append(name)
EPVArray = []
for index,obj in enumerate(names):
    normalname = act.NormalStringPropertyValue(obj, type='string', status='normal')
    EPV = act.ElementPropertyValue(zones[index].elementId, storyNameId, normalname)
    EPVArray.append(EPV)
result = acc.SetPropertyValuesOfElements(EPVArray)
print(result)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 17 Oct 2022 22:01:37 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-Python-API/Customization-Python-Script-ZONE-NUMBERING/m-p/358947#M278</guid>
      <dc:creator>poco2013</dc:creator>
      <dc:date>2022-10-17T22:01:37Z</dc:date>
    </item>
    <item>
      <title>Re: Customization Python Script - ZONE NUMBERING</title>
      <link>https://community.graphisoft.com/t5/Archicad-Python-API/Customization-Python-Script-ZONE-NUMBERING/m-p/359683#M279</link>
      <description>&lt;P&gt;Hi Gerry,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you maybe help, how would the script look like, if i simply want to replace the zone number with a custom property?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a concat expression to automatize the room numbering from different parameters, i just need this actually as the zone number.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 16:19:06 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-Python-API/Customization-Python-Script-ZONE-NUMBERING/m-p/359683#M279</guid>
      <dc:creator>Daniel Pataki</dc:creator>
      <dc:date>2022-10-24T16:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: Customization Python Script - ZONE NUMBERING</title>
      <link>https://community.graphisoft.com/t5/Archicad-Python-API/Customization-Python-Script-ZONE-NUMBERING/m-p/366513#M280</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.graphisoft.com/t5/user/viewprofilepage/user-id/4323"&gt;@Daniel Pataki&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following will provide you with the necessary:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from Archicad import ACConnection

conn = ACConnection.connect()
assert conn

acc = conn.commands
act = conn.types
acu = conn.utilities

# get all zones (returns GUIDs)
elem_all_zones = acc.GetElementsByType('Zone')

# returns GUIDs of prop (Built-ins are non-localized)
prop_znumber = acu.GetBuiltInPropertyId('Zone_ZoneNumber')

# user properties are localized: 'Group', 'Prop Name'
# CHANGE THIS:
prop_pnumber = acu.GetUserDefinedPropertyId('Allgemeine Werte', 'Raumnummer')

propvallist_pnumber = [val.propertyValues[0].propertyValue.value for val in acc.GetPropertyValuesOfElements(elem_all_zones, [prop_pnumber])]

for i, elem in enumerate(elem_all_zones):
    new_zonenumber = act.ElementPropertyValue(
                elem.elementId, prop_znumber, act.NormalStringPropertyValue(propvallist_pnumber[i]))
    # write number back
    acc.SetPropertyValuesOfElements([new_zonenumber])&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 02 Jan 2023 21:43:45 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-Python-API/Customization-Python-Script-ZONE-NUMBERING/m-p/366513#M280</guid>
      <dc:creator>runxel</dc:creator>
      <dc:date>2023-01-02T21:43:45Z</dc:date>
    </item>
  </channel>
</rss>

