OSArch Community

Converting windows into daylight/energy model

  1. M

    I need to get som representative data from objects like windows, doors and curtain wall panels into a text file and wonder if someone can help me with ideas how to do this? Preferable as simple as possible since this operation will be repeated a lot. I am thinking of a python script that could be made into a plugin at some point. The data I need is name/type, width, height, midpoint and normal direction for all selected objects. The objects can originate from CAD, IFC or Speckle and I assume that they are rectangular and rather planar but they might slope.

    /Max

  2. D

    Can you be a bit clearer what you're looking for? I'm confused.

  3. M

    For each window I would like a line in a textfile with the following format

    (centre) (normal) (height) (width)

    The trick part is to get the normal direction since the input could be IFC, Blender from various sources and CAD. This is what I use right now

        from bpy import context as C
    
                for ob in C.selected_objects:
    
                    #Ensure origin is centered on bounding box center
    
                    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='BOUNDS')
    
                    centre = ob.location  # Does this work for all objects? Seems to work in many cases.
    
                    faces_up = (p for p in ob.data.polygons) #This needs to be fixed, if the window contains many surfaces the normal direction is twisted
    
                    normal = max(faces_up, key=lambda f: f.area).normal #Find largest area
    
                    verts = ob.data.vertices
    
                    width = max(v.co.x for v in verts) - min(v.co.x for v in verts) #Get largest value, does not work well for sloping windows.
    
                    depth = max(v.co.y for v in verts) - min(v.co.y for v in verts) #Get smallest value
    
                    appwidth = (maximum(width, depth)) #Make sure the largest of with and depth is choosen
    
                    height = max(v.co.z for v in verts) - min(v.co.z for v in verts) #Custom funcion
  4. G
  5. M

    Thanks a lot, ob.dimensions looks really useful. At least in the IFC-examples I have tried. Still struggeling with ob.matrix_world.to_euler() but I will try as well.

    /Max

Login or Register to reply.