Developer forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Python and property manager option sets

JT1986
Contributor

Hi,

 

I have been learning to use Python for some time to enter data for various elements in Archicad.

 Now, however, the question has arisen for me about the option sets which can be found and created in the property manager.  Is there a way to set predefined value which are located in option sets for elements by using Python?

 

Example 1: There is an self created option set called "Wall type" that contains options "Unspecified (this acts as an default value)", "Type 1", "Type 2" and "Type 3". I would like to set this property value in every wall to "Type 3".

 

Example 2: There is an self created option set called "Furniture definition set" that contains options "Def. 1", "Def. 2" and "Def. 3" and "allow multiple choices" is on. I would like to set this value in every furniture that is classified to "chair" to "Def. 1" and "Def. 2".

 

Is it possible to implement either example at the moment by using Python in Archicad and what kind of code it would need to work right?

 

1 ACCEPTED SOLUTION

Solution
JT1986
Contributor

After a few trial and error rounds I got the script working as I wanted! The solution was to use act.DisplayValueEnumId()  and act.NormalSingleEnumPropertyValue() (or act.NormalMultiEnumPropertyValue() ) types to change values  in the option set lists.

View solution in original post

2 REPLIES 2

JT1986
Contributor

Situation update: I was able to get value type out from the option set with the script below:

 

 

from Archicad import ACConnection
import Archicad
import sys

from Archicad.releases.ac25.b3000types import ElementId
from enum import Enum
conn = ACConnection.connect()

assert conn

acc = conn.commands
act = conn.types
acu = conn.utilities

elements = acc.GetElementsByType('Zone')
BuildingId = acu.GetUserDefinedPropertyId('BUILDING INFORMATION','BELONGS TO THE BUILDING')
zoneNumberId = acu.GetBuiltInPropertyId('Zone_ZoneNumber')
value1 =acc.GetPropertyValuesOfElements(elements,[BuildingId])
value2 =acc.GetDetailsOfProperties([BuildingId])
value3 =acc.GetPropertyValuesOfElements(elements,[zoneNumberId])


PropListArray = []
for index,element in enumerate(elements):
    element = element.elementId
    Buildinginfo1 = str(value1[index].propertyValues[0].propertyValue.value.displayValue)
    Numberinfo = str(value3[index].propertyValues[0].propertyValue.value)
    print(Numberinfo, "Current value is:", Buildinginfo1)

print("------------")

PropListArray2 = []
for index,element in enumerate(elements):
    element = element.elementId
    Buildinginfo2 = str(value2[0].propertyDefinition.possibleEnumValues)
    str1=Buildinginfo2
    def replaceText(str1,substring_list, new_str):
        for string in substring_list:
            if string in str1:
                str1=str1.replace(string,new_str)
        return str1
    final_string=replaceText(str1,["PossibleEnumValuesArrayItem {'enumValue': {'enumValueId': {'displayValue': '","}","[","]","type","displayValue","'",":",","],"")
    print(" Possible options in the list (first enumValueId, second displayValue)---:",final_string)

print("------------")

for values in value1:
    print("ELEMENT RAW DATA VALUE:",values)

print("------------")

for values2 in value2:
    print("BELONGS TO THE BUILDING OPTION SET RAW DATA VALUES:",values2)

 

 

And here's the result:

 

 

C1.001 Current value is: Undenified
C1.003 Current value is: Part of the building 1
C1.002 Current value is: Undenified
C1.004 Current value is: Undenified
C1.005 Current value is: Undenified
C1.006 Current value is: Undenified
C1.007 Current value is: Undenified
------------
 Possible options in the list (first enumValueId, second displayValue)---: Undenified    Undenified Part of the building 1    Part of the building 1 Part of the building 2    Part of the building 2
 Possible options in the list (first enumValueId, second displayValue)---: Undenified    Undenified Part of the building 1    Part of the building 1 Part of the building 2    Part of the building 2
 Possible options in the list (first enumValueId, second displayValue)---: Undenified    Undenified Part of the building 1    Part of the building 1 Part of the building 2    Part of the building 2
 Possible options in the list (first enumValueId, second displayValue)---: Undenified    Undenified Part of the building 1    Part of the building 1 Part of the building 2    Part of the building 2
 Possible options in the list (first enumValueId, second displayValue)---: Undenified    Undenified Part of the building 1    Part of the building 1 Part of the building 2    Part of the building 2
 Possible options in the list (first enumValueId, second displayValue)---: Undenified    Undenified Part of the building 1    Part of the building 1 Part of the building 2    Part of the building 2
 Possible options in the list (first enumValueId, second displayValue)---: Undenified    Undenified Part of the building 1    Part of the building 1 Part of the building 2    Part of the building 2
------------
ELEMENT RAW DATA VALUE: PropertyValuesWrapper {'propertyValues': [{'propertyValue': {'value': {'displayValue': 'Undenified', 'type': 'displayValue'}, 'type': 'singleEnum', 'status': 'normal'}}]}
ELEMENT RAW DATA VALUE: PropertyValuesWrapper {'propertyValues': [{'propertyValue': {'value': {'displayValue': 'Part of the building 1', 'type': 'displayValue'}, 'type': 'singleEnum', 'status': 'normal'}}]}  
ELEMENT RAW DATA VALUE: PropertyValuesWrapper {'propertyValues': [{'propertyValue': {'value': {'displayValue': 'Undenified', 'type': 'displayValue'}, 'type': 'singleEnum', 'status': 'normal'}}]}
ELEMENT RAW DATA VALUE: PropertyValuesWrapper {'propertyValues': [{'propertyValue': {'value': {'displayValue': 'Undenified', 'type': 'displayValue'}, 'type': 'singleEnum', 'status': 'normal'}}]}
ELEMENT RAW DATA VALUE: PropertyValuesWrapper {'propertyValues': [{'propertyValue': {'value': {'displayValue': 'Undenified', 'type': 'displayValue'}, 'type': 'singleEnum', 'status': 'normal'}}]}
ELEMENT RAW DATA VALUE: PropertyValuesWrapper {'propertyValues': [{'propertyValue': {'value': {'displayValue': 'Undenified', 'type': 'displayValue'}, 'type': 'singleEnum', 'status': 'normal'}}]}
ELEMENT RAW DATA VALUE: PropertyValuesWrapper {'propertyValues': [{'propertyValue': {'value': {'displayValue': 'Undenified', 'type': 'displayValue'}, 'type': 'singleEnum', 'status': 'normal'}}]}
------------
BELONGS TO THE BUILDING OPTION SET RAW DATA VALUES: PropertyDefinitionWrapper {'propertyDefinition': {'group': {'name': 'BUILDING INFORMATION'}, 'name': 'BELONGS TO THE BUILDING', 'description': '', 'possibleEnumValues': [{'enumValue': {'enumValueId': {'displayValue': 'Undenified', 'type': 'displayValue'}, 'displayValue': 'Undenified'}}, {'enumValue': {'enumValueId': {'displayValue': 'Part of the building 1', 'type': 'displayValue'}, 'displayValue': 'Part of the building 1'}}, {'enumValue': {'enumValueId': {'displayValue': 'Part of the building 2', 'type': 'displayValue'}, 'displayValue': 'Part of the building 2'}}]}}

 

 

What I can understand from the results is that it seems option set values contains both display- and enumValue types per one choice. I have tried to use "act_SingleEnumPropertyValue" -type to change the value of the zones from "undenified" to "part of the building 1" with no luck.

Solution
JT1986
Contributor

After a few trial and error rounds I got the script working as I wanted! The solution was to use act.DisplayValueEnumId()  and act.NormalSingleEnumPropertyValue() (or act.NormalMultiEnumPropertyValue() ) types to change values  in the option set lists.

View solution in original post

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!