OSArch Community

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

  1. L

    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

  2. L

    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
    
  3. J

    Hi @lraimo, I have edited your post to show the code properly. You can use three quotes (```) above and below to do so.

  4. J

    Look also this thread that is similar.

    ifcopenshell.util.element has functions that can help you get the property sets

  5. M

    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.

  6. L

    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.

  7. L

    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?

  8. M
  9. L

    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.

  10. L

    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)
    
  11. L

    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.

  12. M

    Try:

    
    ifcopenshell.util.element.get_type(IfcElement)
    
  13. L

    That worked, thanks

Login or Register to reply.