Script to Select Polygons / Faces Base on Orientation


I'm kind of a newb scripter and looking for help or tips creating a script that will allow me to select polygons / faces by orientation based on the polygon I currently have selected. I'm not even sure if it's possible. So far I just have have this script attached, which allows me to select polygons based on a set orientation (in this example, an angle of 45 degrees).

I'm wondering if I might be able to use some of this to create the new script but I'm a little lost as to how to input the angle based on what I have selected. Additionally, it would be much more helpful if it didn't selected faces on the opposite side of, say, a bunch of squares. So just the faces on one side of them.

Any help would be GREATLY appreciated!

selectfacesbyorientation_01.ms668 bytes