Converting windows into daylight/energy model

MaxMax
edited June 2022 in General

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

Tagged:

Comments

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

  • 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

  • edited June 2022

    Object dimensions can be inferred directly with the object : width, depth, height = ob.dimensions. You can also infer the object rotation by using the object matrix : ob.matrix_world.to_euler() which will give you the normal with a bit of maths.

    https://docs.blender.org/api/current/mathutils.html#mathutils.Matrix.to_euler

  • 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

Sign In or Register to comment.