IfcOpenShell(Parse)_IFC PropertySet, printing issue

你。 提交于 2019-12-11 14:17:07

问题


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:


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.



来源:https://stackoverflow.com/questions/58839037/ifcopenshellparse-ifc-propertyset-printing-issue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!