<?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 How to set element classifications by the layer with Python add-on in Archicad Python API</title>
    <link>https://community.graphisoft.com/t5/Archicad-Python-API/How-to-set-element-classifications-by-the-layer-with-Python-add/m-p/312851#M100</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create a script that would set same classification value to all elements in specified layer&amp;nbsp;regardless of the element type. At this point I have got the script working but not quite as I hoped. Instead of giving classifications only to the elements in specified layers, script gives same classification value for every element in the project. I might have a guess why it does that, but I have not found a fix for it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;Any solutions for how to get the script working right?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Here's the code:&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from Archicad import ACConnection
import Archicad
import sys
import re

from Archicad.releases.ac25.b3000types import ElementId, ElementPropertyValue
conn = ACConnection.connect()

assert conn

conn = ACConnection.connect()
acc = conn.commands
act = conn.types
acu = conn.utilities

elementIdBuiltInPropertyUserIds = acc.GetAllElements()
Layer = acu.GetBuiltInPropertyId('ModelView_LayerName')
elemenType=acu.GetBuiltInPropertyId('General_Type')
value =acc.GetPropertyValuesOfElements(elementIdBuiltInPropertyUserIds,[Layer])
value2=acc.GetPropertyValuesOfElements(elementIdBuiltInPropertyUserIds,[elemenType])

class1 = acu.FindClassificationSystem('AC_Classification')
class2 = acu.FindClassificationItemInSystem('AC_Classification','Building Element Proxy')
class_id = act.ClassificationId(class1,class2.classificationItemId)

NumberArray = []
for index,element in enumerate(elementIdBuiltInPropertyUserIds):
    element = element.elementId
    Info1 = value[index].propertyValues[0].propertyValue.value
    Info2 = value2[index].propertyValues[0].propertyValue.value
    print("Layer name: ",Info1,"----Element type in layer:", Info2)


if "Structural - Bearing" in str(value):
    elem_classes = []
    for element2 in elementIdBuiltInPropertyUserIds:
        elem_class = act.ElementClassification(element2.elementId,class_id)
        elem_classes.append(elem_class) 
        acc.SetClassificationsOfElements(elem_classes)
        print(elem_class)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And after running the script, here's the outcome:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Layer name:  Structural - Bearing ----Element type in layer: Wall
Layer name:  Structural - Bearing ----Element type in layer: Column
Layer name:  Structural - Bearing ----Element type in layer: Column
Layer name:  Structural - Bearing ----Element type in layer: Column
Layer name:  Model Unit - Zone ----Element type in layer: Zone
Layer name:  Model Unit - Zone ----Element type in layer: Zone
ElementClassification {'elementId': {'guid': 'DE8A1990-E082-4276-BE02-834D0EBF010D'}, 'classificationId': {'classificationSystemId': {'guid': '632C30E5-2B82-4A75-BFAD-D52FEBCE9A4A'}, 'classificationItemId': {'guid': '7272DAE2-F291-4062-A660-574C7E56DC66'}}}
ElementClassification {'elementId': {'guid': 'ED65B0A9-DD68-4086-9E93-09D426134059'}, 'classificationId': {'classificationSystemId': {'guid': '632C30E5-2B82-4A75-BFAD-D52FEBCE9A4A'}, 'classificationItemId': {'guid': '7272DAE2-F291-4062-A660-574C7E56DC66'}}}
ElementClassification {'elementId': {'guid': 'C9A4FC19-4000-4490-B0B7-A29D39AD7EA8'}, 'classificationId': {'classificationSystemId': {'guid': '632C30E5-2B82-4A75-BFAD-D52FEBCE9A4A'}, 'classificationItemId': {'guid': '7272DAE2-F291-4062-A660-574C7E56DC66'}}}
ElementClassification {'elementId': {'guid': 'FA45CD41-0799-4269-91E2-F3BE5839909B'}, 'classificationId': {'classificationSystemId': {'guid': '632C30E5-2B82-4A75-BFAD-D52FEBCE9A4A'}, 'classificationItemId': {'guid': '7272DAE2-F291-4062-A660-574C7E56DC66'}}}
ElementClassification {'elementId': {'guid': '82619F49-B5C5-454F-9DEC-D613F8EEEDE3'}, 'classificationId': {'classificationSystemId': {'guid': '632C30E5-2B82-4A75-BFAD-D52FEBCE9A4A'}, 'classificationItemId': {'guid': '7272DAE2-F291-4062-A660-574C7E56DC66'}}}
ElementClassification {'elementId': {'guid': 'D11CC0E9-21C7-43C9-B3E5-03EFE696DD66'}, 'classificationId': {'classificationSystemId': {'guid': '632C30E5-2B82-4A75-BFAD-D52FEBCE9A4A'}, 'classificationItemId': {'guid': '7272DAE2-F291-4062-A660-574C7E56DC66'}}}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see that the script gives classification "building element proxy" for every element instead giving it only for&amp;nbsp; the elements in the "Structural - Bearing" layer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 24 Oct 2021 17:53:15 GMT</pubDate>
    <dc:creator>JT1986</dc:creator>
    <dc:date>2021-10-24T17:53:15Z</dc:date>
    <item>
      <title>How to set element classifications by the layer with Python add-on</title>
      <link>https://community.graphisoft.com/t5/Archicad-Python-API/How-to-set-element-classifications-by-the-layer-with-Python-add/m-p/312851#M100</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create a script that would set same classification value to all elements in specified layer&amp;nbsp;regardless of the element type. At this point I have got the script working but not quite as I hoped. Instead of giving classifications only to the elements in specified layers, script gives same classification value for every element in the project. I might have a guess why it does that, but I have not found a fix for it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;Any solutions for how to get the script working right?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Here's the code:&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from Archicad import ACConnection
import Archicad
import sys
import re

from Archicad.releases.ac25.b3000types import ElementId, ElementPropertyValue
conn = ACConnection.connect()

assert conn

conn = ACConnection.connect()
acc = conn.commands
act = conn.types
acu = conn.utilities

elementIdBuiltInPropertyUserIds = acc.GetAllElements()
Layer = acu.GetBuiltInPropertyId('ModelView_LayerName')
elemenType=acu.GetBuiltInPropertyId('General_Type')
value =acc.GetPropertyValuesOfElements(elementIdBuiltInPropertyUserIds,[Layer])
value2=acc.GetPropertyValuesOfElements(elementIdBuiltInPropertyUserIds,[elemenType])

class1 = acu.FindClassificationSystem('AC_Classification')
class2 = acu.FindClassificationItemInSystem('AC_Classification','Building Element Proxy')
class_id = act.ClassificationId(class1,class2.classificationItemId)

NumberArray = []
for index,element in enumerate(elementIdBuiltInPropertyUserIds):
    element = element.elementId
    Info1 = value[index].propertyValues[0].propertyValue.value
    Info2 = value2[index].propertyValues[0].propertyValue.value
    print("Layer name: ",Info1,"----Element type in layer:", Info2)


if "Structural - Bearing" in str(value):
    elem_classes = []
    for element2 in elementIdBuiltInPropertyUserIds:
        elem_class = act.ElementClassification(element2.elementId,class_id)
        elem_classes.append(elem_class) 
        acc.SetClassificationsOfElements(elem_classes)
        print(elem_class)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And after running the script, here's the outcome:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Layer name:  Structural - Bearing ----Element type in layer: Wall
Layer name:  Structural - Bearing ----Element type in layer: Column
Layer name:  Structural - Bearing ----Element type in layer: Column
Layer name:  Structural - Bearing ----Element type in layer: Column
Layer name:  Model Unit - Zone ----Element type in layer: Zone
Layer name:  Model Unit - Zone ----Element type in layer: Zone
ElementClassification {'elementId': {'guid': 'DE8A1990-E082-4276-BE02-834D0EBF010D'}, 'classificationId': {'classificationSystemId': {'guid': '632C30E5-2B82-4A75-BFAD-D52FEBCE9A4A'}, 'classificationItemId': {'guid': '7272DAE2-F291-4062-A660-574C7E56DC66'}}}
ElementClassification {'elementId': {'guid': 'ED65B0A9-DD68-4086-9E93-09D426134059'}, 'classificationId': {'classificationSystemId': {'guid': '632C30E5-2B82-4A75-BFAD-D52FEBCE9A4A'}, 'classificationItemId': {'guid': '7272DAE2-F291-4062-A660-574C7E56DC66'}}}
ElementClassification {'elementId': {'guid': 'C9A4FC19-4000-4490-B0B7-A29D39AD7EA8'}, 'classificationId': {'classificationSystemId': {'guid': '632C30E5-2B82-4A75-BFAD-D52FEBCE9A4A'}, 'classificationItemId': {'guid': '7272DAE2-F291-4062-A660-574C7E56DC66'}}}
ElementClassification {'elementId': {'guid': 'FA45CD41-0799-4269-91E2-F3BE5839909B'}, 'classificationId': {'classificationSystemId': {'guid': '632C30E5-2B82-4A75-BFAD-D52FEBCE9A4A'}, 'classificationItemId': {'guid': '7272DAE2-F291-4062-A660-574C7E56DC66'}}}
ElementClassification {'elementId': {'guid': '82619F49-B5C5-454F-9DEC-D613F8EEEDE3'}, 'classificationId': {'classificationSystemId': {'guid': '632C30E5-2B82-4A75-BFAD-D52FEBCE9A4A'}, 'classificationItemId': {'guid': '7272DAE2-F291-4062-A660-574C7E56DC66'}}}
ElementClassification {'elementId': {'guid': 'D11CC0E9-21C7-43C9-B3E5-03EFE696DD66'}, 'classificationId': {'classificationSystemId': {'guid': '632C30E5-2B82-4A75-BFAD-D52FEBCE9A4A'}, 'classificationItemId': {'guid': '7272DAE2-F291-4062-A660-574C7E56DC66'}}}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see that the script gives classification "building element proxy" for every element instead giving it only for&amp;nbsp; the elements in the "Structural - Bearing" layer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Oct 2021 17:53:15 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-Python-API/How-to-set-element-classifications-by-the-layer-with-Python-add/m-p/312851#M100</guid>
      <dc:creator>JT1986</dc:creator>
      <dc:date>2021-10-24T17:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to set element classifications by the layer with Python add-on</title>
      <link>https://community.graphisoft.com/t5/Archicad-Python-API/How-to-set-element-classifications-by-the-layer-with-Python-add/m-p/312881#M101</link>
      <description>&lt;P&gt;Try replacing the last "if" with&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;elem_classes = []
    for index,element2 in enumerate(elementIdBuiltInPropertyUserIds):
        if "Structural - Bearing" == value[index].propertyValues[0].propertyValue.value:
            elem_class = act.ElementClassification(element2.elementId,class_id)
            elem_classes.append(elem_class) 
acc.SetClassificationsOfElements(elem_classes)
print(elem_classes)&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 24 Oct 2021 23:19:06 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-Python-API/How-to-set-element-classifications-by-the-layer-with-Python-add/m-p/312881#M101</guid>
      <dc:creator>poco2013</dc:creator>
      <dc:date>2021-10-24T23:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to set element classifications by the layer with Python add-on</title>
      <link>https://community.graphisoft.com/t5/Archicad-Python-API/How-to-set-element-classifications-by-the-layer-with-Python-add/m-p/313044#M102</link>
      <description>&lt;P&gt;Thank you very much Gerry! Your solution made the script do exactly what it was meant to do!&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 05:56:49 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-Python-API/How-to-set-element-classifications-by-the-layer-with-Python-add/m-p/313044#M102</guid>
      <dc:creator>JT1986</dc:creator>
      <dc:date>2021-10-26T05:56:49Z</dc:date>
    </item>
  </channel>
</rss>

