If you're reading this, we've just migrated servers! If anything looks broken please email dion@thinkmoult.com :)

Getting OverallHeight from a IFCWindow

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

Comments

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

  • 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'

  • 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)
    
  • 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'

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

  • 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.

    bruno_perdigao
Sign In or Register to comment.