<?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: Insert wall property on door beloning to wall in Archicad Python API</title>
    <link>https://community.graphisoft.com/t5/Archicad-Python-API/Insert-wall-property-on-door-beloning-to-wall/m-p/632838#M1050</link>
    <description>&lt;P&gt;This is what I have managed so far.&lt;BR /&gt;I have managed to extract the GUID from the element and propery with the value. I would just need to move the value from one GUID to another. The challenge is to know which door is in which wall. Maybe impossible...&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;import archicad
from archicad import ACConnection
from typing import List

# Etablera en anslutning till Archicad
conn = ACConnection.connect()
if not conn:
    print("Unable to connect to Archicad")
else:
    print("Connection established")

# Få kommandoreferenser
acc = conn.commands
act = conn.types

# Steg 1: Hämta alla property-ID:n och filtrera ut den du vill ha
property_name = "6.3 Ljudreduktion"
property_set = "SS 81 73 40:2021"

# Normalisera strängar för att undvika jämförelseproblem
def normalize_string(s):
    return s.strip().lower()

normalized_property_name = normalize_string(property_name)
normalized_property_set = normalize_string(property_set)

# Hämta alla properties
all_property_ids = acc.GetAllPropertyIds()

# Filtrera efter property set och property name
target_property_id = None
for prop in all_property_ids:
    prop_details = acc.GetDetailsOfProperties([prop])
    prop_definition = prop_details[0].propertyDefinition  # Hämta property definition

    # Jämför nu med 'group.name' för property set
    if normalize_string(prop_definition.group.name) == normalized_property_set and normalize_string(prop_definition.name) == normalized_property_name:
        target_property_id = prop
        break

if not target_property_id:
    print(f"Property '{property_name}' under set '{property_set}' not found.")
else:
    # Steg 2: Hämta alla element och deras properties
    elements = acc.GetAllElements()

    for element in elements:
        # Extrahera GUID för elementet
        element_guid = element.elementId.guid
        print(f"Element GUID: {element_guid}")
        
        # Extrahera elementets property-värde för den specifika property
        try:
            property_values = acc.GetPropertyValuesOfElements([element.elementId], [target_property_id])
            if property_values and property_values[0].propertyValues:
                for prop in property_values[0].propertyValues:
                    property_value = prop.propertyValue
                    print(f"  Property Name: {property_name}")
                    
                    # Skriv ut värdet om det inte är tomt
                    if isinstance(property_value, act.NormalStringPropertyValue):
                        if property_value.value:
                            print(f"  Value: {property_value.value}")
                        else:
                            print(f"  Value is empty for element {element_guid}")
                    else:
                        print(f"Unhandled property value type for element {element_guid}")
            else:
                print("No properties found for this element")
        except Exception as e:
            print(f"Error fetching properties: {e}")&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 27 Sep 2024 09:38:44 GMT</pubDate>
    <dc:creator>Gortz</dc:creator>
    <dc:date>2024-09-27T09:38:44Z</dc:date>
    <item>
      <title>Insert wall property on door beloning to wall</title>
      <link>https://community.graphisoft.com/t5/Archicad-Python-API/Insert-wall-property-on-door-beloning-to-wall/m-p/632796#M1049</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to retrieve a property from a wall and insert the value of the property on, for example, doors and windows located in that specific wall with a Python Script or is it a limitation of the Python API or even Archicad?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this case, we want to get the sound reduction property from a wall and push it onto the door belonging to that wall.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2024 08:32:57 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-Python-API/Insert-wall-property-on-door-beloning-to-wall/m-p/632796#M1049</guid>
      <dc:creator>Gortz</dc:creator>
      <dc:date>2024-09-27T08:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: Insert wall property on door beloning to wall</title>
      <link>https://community.graphisoft.com/t5/Archicad-Python-API/Insert-wall-property-on-door-beloning-to-wall/m-p/632838#M1050</link>
      <description>&lt;P&gt;This is what I have managed so far.&lt;BR /&gt;I have managed to extract the GUID from the element and propery with the value. I would just need to move the value from one GUID to another. The challenge is to know which door is in which wall. Maybe impossible...&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;import archicad
from archicad import ACConnection
from typing import List

# Etablera en anslutning till Archicad
conn = ACConnection.connect()
if not conn:
    print("Unable to connect to Archicad")
else:
    print("Connection established")

# Få kommandoreferenser
acc = conn.commands
act = conn.types

# Steg 1: Hämta alla property-ID:n och filtrera ut den du vill ha
property_name = "6.3 Ljudreduktion"
property_set = "SS 81 73 40:2021"

# Normalisera strängar för att undvika jämförelseproblem
def normalize_string(s):
    return s.strip().lower()

normalized_property_name = normalize_string(property_name)
normalized_property_set = normalize_string(property_set)

# Hämta alla properties
all_property_ids = acc.GetAllPropertyIds()

# Filtrera efter property set och property name
target_property_id = None
for prop in all_property_ids:
    prop_details = acc.GetDetailsOfProperties([prop])
    prop_definition = prop_details[0].propertyDefinition  # Hämta property definition

    # Jämför nu med 'group.name' för property set
    if normalize_string(prop_definition.group.name) == normalized_property_set and normalize_string(prop_definition.name) == normalized_property_name:
        target_property_id = prop
        break

if not target_property_id:
    print(f"Property '{property_name}' under set '{property_set}' not found.")
else:
    # Steg 2: Hämta alla element och deras properties
    elements = acc.GetAllElements()

    for element in elements:
        # Extrahera GUID för elementet
        element_guid = element.elementId.guid
        print(f"Element GUID: {element_guid}")
        
        # Extrahera elementets property-värde för den specifika property
        try:
            property_values = acc.GetPropertyValuesOfElements([element.elementId], [target_property_id])
            if property_values and property_values[0].propertyValues:
                for prop in property_values[0].propertyValues:
                    property_value = prop.propertyValue
                    print(f"  Property Name: {property_name}")
                    
                    # Skriv ut värdet om det inte är tomt
                    if isinstance(property_value, act.NormalStringPropertyValue):
                        if property_value.value:
                            print(f"  Value: {property_value.value}")
                        else:
                            print(f"  Value is empty for element {element_guid}")
                    else:
                        print(f"Unhandled property value type for element {element_guid}")
            else:
                print("No properties found for this element")
        except Exception as e:
            print(f"Error fetching properties: {e}")&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 27 Sep 2024 09:38:44 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-Python-API/Insert-wall-property-on-door-beloning-to-wall/m-p/632838#M1050</guid>
      <dc:creator>Gortz</dc:creator>
      <dc:date>2024-09-27T09:38:44Z</dc:date>
    </item>
  </channel>
</rss>

