Select faces by altitude

Hi! I have recently started looking into Ruby scripting, and I have encountered a problem that I can’t solve. I have code that allows me to create a horizontal cut through a terrain component. The height of the cut is defined by user input. My problem right now is how to select the faces inside the terrain component that are below the cutting line in the z-axis. No matter what i have tried so far I end up selecting all faces. Any ideas would be greatly appreciated!

Similar topic:


Thank you!