IfcOpenShell(Parse)_IFC PropertySet, printing issue

362 Views Asked by At

Hy, I am new to programming and I have problems with printing my property sets and values.

I have more elements in my IFC and want to Parse all Property Sets and values. My current result is elements ID(for every element), but it takes the attributes(property sets and values) form the first one. Sketch: see image

My code:

import ifcopenshell

ifc_file = ifcopenshell.open('D:\PZI_9-1_1441_LIN_CES_1-17c-O_M-M3.ifc')
products = ifc_file.by_type('IFCPROPERTYSET')
for product in products:
    print(product.is_a())
    print(product) # Prints  
    Category_Name_1 = ifc_file.by_type('IFCBUILDINGELEMENTPROXY')[0]
    for definition in Category_Name_1.IsDefinedBy:
        property_set = definition.RelatingPropertyDefinition

        headders_list = []
        data_list = []
        max_len = 0

        for property in property_set.HasProperties:
            if property.is_a('IfcPropertySingleValue'):           

                headers = (property.Name)
                data= (property.NominalValue.wrappedValue)
                    #print(headders)
                headders_list.append(headers)
                if len(headers) > max_len: max_len = len(headers)
                    #print(data)               
                data_list.append(data)
                if len(data) > max_len: max_len = len(data)           

    headders_list = [headers.ljust(max_len) for headers in headders_list]
    data_list = [data.ljust(max_len) for data in data_list]

    print(" ".join(headders_list))
    print(" ".join(data_list))

Has somebody a solution?

Thanks and kind regards,

1

There are 1 best solutions below

0
On

On line:

    Category_Name_1 = ifc_file.by_type('IFCBUILDINGELEMENTPROXY')[0]

it seems that you are referring always to the first IfcBuildingElementProxy object (because of the 0-index). The index should be incremented for each product, I guess.