List property set, property names and element types that have this

How is it possible to list all property set, property names and element types that have this in ifc file using IfcOpenShell Python. End result should be something like this

My code so far

Comments

  • edited April 2021

    Got the loop working, but still I do not know how to get property data type. Also if property set is attached to multiple ifc types would like to get result like this
    AR_001-002(IfcColumn, IfcRailing )
    001_Nimetus
    002_Tüüp
    At the moment get result like this
    AR_001-002(IfcColumn)
    001_Nimetus
    002_Tüüp
    AR_001-002(IfcRailing)
    001_Nimetus
    002_Tüüp
    Code so war

        import ifcopenshell
        import tkinter as tk
        from tkinter import filedialog
        root = tk.Tk()
        root.withdraw()
        file_path =  filedialog.askopenfilename(title = "Vali IFC fail",filetypes = (("IFC","*.ifc"),("Kõik failid","*.*")))
        print(file_path)
        ifc_file = ifcopenshell.open(file_path)
        for IfcType in ifc_file.types_with_super():
            try:
                for definition in ifc_file.by_type(IfcType)[0].IsDefinedBy:
                    if definition.is_a('IfcRelDefinesByProperties'):
                        property_set = definition.RelatingPropertyDefinition
                        substring = 'Pset_'
                        if substring in property_set.Name:
                            #print(property_set.Name + "on sees Pset_")
                            pass
                        else:
                            print(property_set.Name + "(" + IfcType + ")")
                            for property in property_set.HasProperties:
                                if property.is_a('IfcPropertySingleValue'):
                                    print(" " + property.Name)
                                    #print(" " + property.Type) Not working
            except:
                pass
    
  • Hi @lraimo, I have edited your post to show the code properly. You can use three quotes (```) above and below to do so.

  • Look also this thread that is similar.
    ifcopenshell.util.element has functions that can help you get the property sets

  • Property types can be retrieved either through the property template definition, or the stored nominal value attribute. Try property.NominalValue, as well as property.NominalValue.attribute_type(0), or property.NominalValue.is_a(), or type(property.NominalValue.wrappedValue) depending on what you're after.

  • edited April 2021

    property.NominalValue.is_a() was what I needed. Thanks.
    property.NominalValue I get IfcText('Curtain Wall').
    property.NominalValue.wrappedValue I get Curtain Wall.
    property.NominalValue.is_a() I get IfcText.
    property.NominalValue.attribute_type(0) did not work.

  • With code for IfcType in ifc_file.types_with_super() I get IFC Element, sample value IfcSlab
    But there also is
    IfcElementType , sample value IfcSlabType
    PredefinedType, sample value ROOF
    Is it possible to get those values by Python IfcOpenShell?

  • It sounds like you want to query the schema, not an individual file. This has been documented to an extent here: https://wiki.osarch.org/index.php?title=IfcOpenShell_code_examples#Exploring_IFC_schema

  • edited April 2021

    No I want to get IfcElement (for example IfcSlab), IfcElementType (for example IfcSlabType), and PredefinedType ( for example Roof) for all PropertySets in IfcFile. I found a way how to get IfcElement and PredefinedType, but have not found a way to get IfcElementType.

  • edited April 2021

    My code:

    import ifcopenshell
    file_path = 'File path'
    print(file_path)
    ifc_file = ifcopenshell.open(file_path)
    IfcElements = ifc_file.by_type('IfcSlab')
    for IfcElement in IfcElements:
        print(IfcElement.is_a())
        print(IfcElement.PredefinedType)
    
  • edited April 2021

    Seems that both IfcElement and IfcElementType can be obtained with ifc_file.by_type(). But there should be connection between them because in viewer both are connected to one element.

  • Try:

    ifcopenshell.util.element.get_type(IfcElement)
    
  • That worked, thanks

Sign In or Register to comment.