I have a question concerning face normals. I got a 3dm-file with a couple of houses modeled from surfaces. In Grasshopper I wrote a little script that detects all the roof surfaces by normal vector (z > 0) and categorizes them by angle. Using it on this model however didn’t show the desired result, because, as I figured out, the face normals are all over the place. Normally when I got this kind of data (it’s LOD2 data), all normals would’ve been pointing outwards (from the house point of view), but here this isn’t the case as you can see in the picture. Backfaces are coloured blue and frontfaces grey. Normally all outside faces should be grey. For using my GH script the correct direction of the normals is really important.
Is there any way in selecting objects by their normal direction for flipping them easier? And second question: How can we make sure, that when editing LOD2 data and adding surfaces, roofs will have their normal pointing upwards and bottoms down etc. so this problem doesn’t occur in the first place? I hope anyone can give me some advice.
Thanks in advance
Normally joining the surfaces will cause all the normals to face in a uniform direction. If the objects are closed, the normals should face outwards. If not, the result will likely be random. From your image, many of the objects appear to have missing surfaces.
It’s easy to check and flip the normals of surfaces facing in the general Z direction - the script below does that. Basically it just compares the angle of surfaces’ normal vectors to the +Z vector and if any are over 90° it flips that surface.
However, it’s not easy to determine the orientation (relative to world Z) of individual unjoined fully vertical surfaces, because there is no concept of “outside” if they are not joined to other surfaces to form a shell. So the script is designed to ignore those vertical surfaces. From your image above, that would mean that the script will only fix the blue surfaces that are at an angle to the vertical.
UnifyNormalsZ.py (1.7 KB)
Thank you for the explanation and the python script! Yes, it seems like the file got corrupted, so with the original file it’s a lot better. Still good to know, that closed objects “unify” their normals.