OSArch Community

Getting OverallHeight from a IFCWindow

  1. M

    I wonder if somebody knows how to get OverallHeight and Width from a selected IFCWindow? I guess you first need to determine if they have these attributes. I just tried

    from bpy import context as C
    
     for ob in C.selected_objects:
    
      print (ob.OverallHeight)

    but of cource it was not that simple

  2. M

    I thought the name might be a custom property and used bpy.data.objects[str(obj.name)]['name']) but no luck.

  3. M

    Ok, I solved it kind of

    from blenderbim.bim.ifc import IfcStore
    
    ifc_data = IfcStore.get_file()
    
    windows = ifc_data.by_type('IfcWindow')
    
    for window in windows:
    
        print(window.OverallHeight)
    
        print(window.OverallWidth)

    gives me the height and width of all windows but the problem is that I want the user to select the windows like

    import bpy
    
    selection = bpy.context.selected_objects
    
    for  obj in selection: 
    
        if obj.name.startswith("IfcWindow"):
    
            print (obj.OverallHeight)

    but then I get AttributeError: 'Object' object has no attribute 'OverallHeight'

  4. B

    Hi @Max, I think the problem is that you are trying to access the IFC property through the Blender Object. You have to get the IFC entity from the Blender object first. I haven't fully tested it, but maybe this will work:

    
    import bpy
    
    import blenderbim.tool as tool
    
    from blenderbim.bim.ifc import IfcStore
    
    ifc_data = IfcStore.get_file()
    
    selection = bpy.context.selected_objects
    
    for  obj in selection: 
    
        if obj.name.startswith("IfcWindow"):
    
            ifc_entity = tool.Ifc.get_entity(obj) #gets the Ifc Entity from the Blender object
    
            print (ifc_entity.OverallHeight)
    
  5. M

    Thanks a lot, I suspected something like this. For some reason tool.Ifc.get_entity(obj) gets "None" and then AttributeError: 'NoneType' object has no attribute 'OverallHeight'

  6. B

    I tested with two different files, and it worked for me. Maybe it's something with the file?

  7. M

    I feel like a complete idiot. I downloaded the IFC from this forum but I guess it was too experimental. With a typical Revit file it worked fine. Thanks for all your help.

Login or Register to reply.