BIM Coordinator Program (INT) April 22, 2024

Find the next step in your career as a Graphisoft Certified BIM Coordinator!

Archicad Python API
About automating tasks in Archicad using the Python API.
SOLVED!

Getting "Show On Renovation Filter" parameter in Python

pedrocollares
Enthusiast

I have a few renovation filters set in my project meant to represent different 'Design options'. At the moment those options consist only of zones, as the following:

 

pedrocollares_1-1696181363856.png

pedrocollares_2-1696181377632.png

 

I'm putting up some routines to extract zone information using Python. I'd like to extract those zone informations of each of those design options which I used the renovation filter to model. Is there a way to access the "Show On Renovation Filter" parameter of elements with Python? Is the only way to achieve that creating a custom property?

 

Thanks in advance!

Architect / BIM Manager at IDEIA1 - www.ideia1.com.br
Archicad 26 / Windows 10 64
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
JT1986
Booster

Hello all,


Actually you can get the information of the renovation status with Python API without workarounds. There is two built-in properties that allow you to get information about either the renovation status of the element or in which renovation filter element is shown.

 

Those properties are these two:

BuiltInPropertyUserId {'nonLocalizedName': 'Category_RenovationStatus', 'type': 'BuiltIn'}

BuiltInPropertyUserId {'nonLocalizedName': 'Category_ShowOnRenovationFilter', 'type': 'BuiltIn'}

 

I wrote a little script that you can test. Hope it works for you.

 

 

from archicad import ACConnection

conn = ACConnection.connect()
assert conn

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

elements = acc.GetAllElements()
ElementID = acu.GetBuiltInPropertyId('General_ElementID')
ElementTypes = acu.GetBuiltInPropertyId('General_Type')
RenovationID = acu.GetBuiltInPropertyId('Category_RenovationStatus')
FilterID = acu.GetBuiltInPropertyId('Category_ShowOnRenovationFilter')
ElementValues1 = acc.GetPropertyValuesOfElements(elements, [RenovationID])
ElementValues2 = acc.GetPropertyValuesOfElements(elements, [FilterID])
ElementIDValues = acc.GetPropertyValuesOfElements(elements, [ElementID])
ElementTypeValues = acc.GetPropertyValuesOfElements(elements, [ElementTypes])

print("----Renovation status:----")
for value in range(len (elements)):
    Statusvalue=str(ElementValues1[value].propertyValues[0].propertyValue.value)
    IDvalue1 = str(ElementIDValues[value].propertyValues[0].propertyValue.value)
    Typevalue1 = str(ElementTypeValues[value].propertyValues[0].propertyValue.value)
    print("Element Type:",Typevalue1, "---",Statusvalue, "___ELEMENT ID:", IDvalue1)
print("")
print("---Show on renovation filter:----")
for value2 in range(len (elements)):
    Filtervalue=str(ElementValues2[value2].propertyValues[0].propertyValue.value)
    IDvalue2 = str(ElementIDValues[value2].propertyValues[0].propertyValue.value)
    Typevalue2 = str(ElementTypeValues[value2].propertyValues[0].propertyValue.value)
    print("Element Type:",Typevalue2, "---",Filtervalue,"___ELEMENT ID:", IDvalue2)

 

 

 

Below you can see the result after running the script (Element type, Renovation and element ID).

JT1986_1-1696232970848.png

 

 

-JT

 

View solution in original post

5 REPLIES 5

Update: My answer is wrong sorry! See the answer from @JT1986 for the correct answer.

Hi Pedro!

Renovation filters are not available with the standard Python API. You can check what's available in the JSONInterfaceDocumentation.

Unfortunately searching for "Renovation" doesn't turn up any command.

 

I can think of two possible workarounds:

  1. Already mentioned by you: Create a custom expression property which basically duplicates the "Show On Renovation Filter" information.
  2. Add a new command to the Additional JSON Commands project (hard without previous C++ experience)

 

Hope that Helps!

Bernd Schwarzenbacher - Archicad Add-On Developer - Get Add-Ons & Archicad Tips on my Website: Archi-XT.com
Solution
JT1986
Booster

Hello all,


Actually you can get the information of the renovation status with Python API without workarounds. There is two built-in properties that allow you to get information about either the renovation status of the element or in which renovation filter element is shown.

 

Those properties are these two:

BuiltInPropertyUserId {'nonLocalizedName': 'Category_RenovationStatus', 'type': 'BuiltIn'}

BuiltInPropertyUserId {'nonLocalizedName': 'Category_ShowOnRenovationFilter', 'type': 'BuiltIn'}

 

I wrote a little script that you can test. Hope it works for you.

 

 

from archicad import ACConnection

conn = ACConnection.connect()
assert conn

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

elements = acc.GetAllElements()
ElementID = acu.GetBuiltInPropertyId('General_ElementID')
ElementTypes = acu.GetBuiltInPropertyId('General_Type')
RenovationID = acu.GetBuiltInPropertyId('Category_RenovationStatus')
FilterID = acu.GetBuiltInPropertyId('Category_ShowOnRenovationFilter')
ElementValues1 = acc.GetPropertyValuesOfElements(elements, [RenovationID])
ElementValues2 = acc.GetPropertyValuesOfElements(elements, [FilterID])
ElementIDValues = acc.GetPropertyValuesOfElements(elements, [ElementID])
ElementTypeValues = acc.GetPropertyValuesOfElements(elements, [ElementTypes])

print("----Renovation status:----")
for value in range(len (elements)):
    Statusvalue=str(ElementValues1[value].propertyValues[0].propertyValue.value)
    IDvalue1 = str(ElementIDValues[value].propertyValues[0].propertyValue.value)
    Typevalue1 = str(ElementTypeValues[value].propertyValues[0].propertyValue.value)
    print("Element Type:",Typevalue1, "---",Statusvalue, "___ELEMENT ID:", IDvalue1)
print("")
print("---Show on renovation filter:----")
for value2 in range(len (elements)):
    Filtervalue=str(ElementValues2[value2].propertyValues[0].propertyValue.value)
    IDvalue2 = str(ElementIDValues[value2].propertyValues[0].propertyValue.value)
    Typevalue2 = str(ElementTypeValues[value2].propertyValues[0].propertyValue.value)
    print("Element Type:",Typevalue2, "---",Filtervalue,"___ELEMENT ID:", IDvalue2)

 

 

 

Below you can see the result after running the script (Element type, Renovation and element ID).

JT1986_1-1696232970848.png

 

 

-JT

 

Great! Thanks a bunch 🙂

 

@BerndSchwarzenbacher your first suggestion is exactly how I have it set up atm

 

But it's always best not to rely on custom properties in those routines. I'll follow the solution brang up by @JT1986 

Architect / BIM Manager at IDEIA1 - www.ideia1.com.br
Archicad 26 / Windows 10 64
pedrocollares
Enthusiast

Bringing up this topic again.

 

Why 'Category_ShowOnRenovationFilter' returns something that looks like a dictionary, instead of simply a string containing the Renovation Filter's name?

 

I'd like to use only the name string of the renovation filter, and in case it is "AllRelevantFilters", use that as a name as well. I tried using the "type" value as a key to return the value assigned to the first key of the dict, but with no success. Seems to me it isn't actually a dictionary.

Architect / BIM Manager at IDEIA1 - www.ideia1.com.br
Archicad 26 / Windows 10 64

The response objects contain more information than just the values because properties can vary a lot. So the same query can lead to a lot of different results depending on the element and the property itself. The extra information is necessary to differentiate between all the different results.

The objects themselves are not dictionaries. It's just that their string representation looks very similar to dictionaries. You can often convert them to dictionaries with .to_dict(), but I wouldn't necessary recommend it. I think it's better to access the respective members of the objects.

Here's an example how you could get the value depending on the type:

 

from archicad import ACConnection

conn = ACConnection.connect()
assert conn

acc = conn.commands
acu = conn.utilities

elements = acc.GetAllElements()

properties = [
    'General_ElementID',
    'General_Type',
    'Category_RenovationStatus',
    'Category_ShowOnRenovationFilter',
]
propertyGuids = [acu.GetBuiltInPropertyId(propName) for propName in properties]

propValsOfAllElems = acc.GetPropertyValuesOfElements(elements, propertyGuids)

for propValsOfOneElem in propValsOfAllElems:
    for propDef, propVal in zip(properties, propValsOfOneElem.propertyValues):
        value = ''
        if propVal.propertyValue.type == 'string':
            value = propVal.propertyValue.value
        elif propVal.propertyValue.type == 'singleEnum':
            value = propVal.propertyValue.value.nonLocalizedValue
        else:
            value = 'Evaluation for this property type not yet implemented!'

        print(propDef + ':', value)

    print()

 

 
Feel free to ask any questions about the code in case something is unclear!

 

Hope that helps,

Bernd

Bernd Schwarzenbacher - Archicad Add-On Developer - Get Add-Ons & Archicad Tips on my Website: Archi-XT.com
Learn and get certified!