I use two methods:
1. Search for the largest surface, usually this is a window pane and use the normal direction for this surface.
2. Make a bounding box around the window and use method 1 on on this box.
from bpy import context as C
for ob in C.selected_objects:
mw = ob.matrix_world #Normal direction should be according to world
N = mw.inverted_safe().transposed().to_3x3() #Normal direction should be according to world
#Make sure only meshes are selected
if ob.type =='MESH': #Ensure origin is centered on bounding box center
faces_up = (p for p in ob.data.polygons)
ob2 = max(faces_up, key = lambda f: f.area) #Get largest area in the collection
n = N @ ob2.normal
I became curious, could you share some snippets of your python script?
Hi @coen I am yet to get this script done. What I am trying to do is to first find the vertical face of an ifcDiscreteAccessory that has the least surface area and then get the direction of the normal for that particular face. I am trying to doing this through ifcopenshell and pythonOCC. Will share the script once done
You might want to investigate some of the code in ifcopenshell.util.shape which provides convenience functions for calculating areas and isolating by normal.
Comments
@Max curious to know if you had this worked out? I am also trying to get normals through a python script.
I use two methods:
1. Search for the largest surface, usually this is a window pane and use the normal direction for this surface.
2. Make a bounding box around the window and use method 1 on on this box.
I became curious, could you share some snippets of your python script?
I use something like this
In IFC, Windows should have their local +Y direction as its normal. So it should be as simple as this in Blender:
Or if you want to get it directly in IFC you can do (it's a numpy array):
Hi @coen I am yet to get this script done. What I am trying to do is to first find the vertical face of an
ifcDiscreteAccessory
that has the least surface area and then get the direction of the normal for that particular face. I am trying to doing this through ifcopenshell and pythonOCC. Will share the script once doneYou might want to investigate some of the code in
ifcopenshell.util.shape
which provides convenience functions for calculating areas and isolating by normal.