# Sort Surfaces by Normal Orientation

Hello

I have been working with large scale map files. Currently, I am trying to make a drawing of an orthographic projection of all of the houses on my site. I have made already sheared my buildings etc. However, what I would love to do is separate the roof, west facing walls, south facing walls, and all remaining walls into four separate layers. The purpose of this is to export everything into illustrator, and to be able to paint each of these categories different colours to create a shaded effect. The image below should explain what I mean.

Obviously this is simple enough to do by hand. However I have hundreds of buildings like this on my site. I found a grasshopper add-on in Ladybug called â€śSeparate by Normalâ€ť which partially works - it will select the roof layer, and the west facing walls. However it will not separate any other oriented walls. Can someone explain a simple process, script, or addition to my grasshopper code to make this work?

ForumPost2.3dm (982.7 KB) ForumPostGH.gh (20.0 KB)

Hello - I think I would do this sorting before any shearing, it will be less ambiguous for the checker - but youâ€™ll want to get the surface normals and check whether they are parallel or antiparallel to the world x/y and z axes. For angled faces, youâ€™ll need to look for vector angles and pick the direction that has the smallest angle to x, y or z.

-Pascal

do you have any recommendation on how to do the latter part? unfortunately my grasshopper knowledge is very limited.

Hello - see if this GH gets you anywhere. (use on pre-sheared surfacesâ€¦)

WallsToLayers.gh (14.9 KB)

-Pascal

Wow, thank you so much. I wish I had this level of grasshopper knowledge! This is exactly what I needed.

Hello - it looked like being pretty annoying to figure out, for me anyway, using just GH components, so short-cut with a couple of very small scripts in python components. Otherwise Iâ€™d have let you struggle moreâ€¦

-Pascal

Dear Pascal,

your Python Script works amazing for me as well. I was wondering however, is it also possible to rewrite the Script, so that it exports North, North-East, East, â€¦ ? Which part of the code would i need to modify for that? I am trying to get better in Python, but I also just started my first Python Rhino Experiments.

I would be very happy for your help.

Best Regards
Max

Hi Max - please PM me with a small example. Iâ€™ll try to help, but you may need to prod me a few times, my current work pile it pretty high. If you want to play, I thnk, if I understand what you need, you need to check the surface normals against vectors that are at the angles you care about - not just World X (1,0,0), Y(0,1,0), but also at 45 degrees, (1,1,0), (-1,-1,0) etc.etc

-Pascal

Thank you for the quick response! I actually managed myself just now by adding the (1,1,0) (and the others) vectors in the Checklist and giving them names in the right order. It works perfectly now

Best
Max

1 Like

Dear Pascal,

I am still working on this component and would like to optimize it even more. However, I am facing some struggles and I cannot find the problem with them:

What I imagine is a Check of an entire geometry and the distribution to layers, as we discussed before. The extension shall be the distribution of surfaces to the â€śFlat Roofâ€ť â€śFloorâ€ť and â€śTilted Roofâ€ť. However, depending on the angle of my tilted roof geometry, the python script puts the surface either on the wall layers or the roof layers. I do not know how the height is influencing this issue.

Do you have an idea?

Would appreciate it a lot.

Best
Maximilian
Test.gh (6.1 KB)

This is the layer name and vector information extracted from your script:

As you can see, the vectors you have defined for your â€śTilted Roofâ€ť layers all have theta angles (slope or pitch values) of either 45Â° or 35.26Â°. If your roof surfaces arenâ€™t created at one of these slope angles, you are going to get unexpected results.

I have re-written your file using standard grasshopper components. The GhPython Script component is still used but only to create layers and to move the surfaces to the appropriate layers.

orientation_Test_kr.gh (33.2 KB)

-Kevin

1 Like

Thank you very much Kevin, it works perfectly.

I am wondering if the same achievement could have been done with a modification of the Python Component only? For example that the component has to check if the surface normal is within a certain degree ratio? I thought that a Vector3d(0,0,0<1) would search for all vectors that are 0 in x and y but have a tilt in the z direction. But I guess Python cannot read it like this right?
Don`t get me wrong here. My entire Grasshopper Tool will become very big and I try to reduce the amount of visual components to a minimum for better overview and understanding.

But if you think this cannot be achieved in a Python script just let me know

Sure, give this a try and let me know if you find any problems:

orientation_Test_kr.02.gh (5.7 KB)

-Kevin

it works perfectly thank you so much!!!

Do you have any recommendation where I can learn such Rhino Python Scripting Skills? I am very eager to learn, but the field of youtube tutorials seems very scarce.

A good place to start Rhino - Rhino.Python Guides

1 Like