Calculating orientation of each side of polygon using ArcPy?

If you just want majority orientation, check out @Mapperz 's answer above.

Otherwise, as you say you could split the polygons into lines using the Polygon To Line tool. This adds a left and right FID field, where the field is -1 if there is no outer polygon - this can cause a bit of mucking about though if your buildings are adjacent or overlap.

From there you could split your lines at every vertex (maybe use Split into COGO lines), and then calculate the angles on each of the lines (potentially by Updating COGO attributes).

Assuming you have your angle field calculated from North the the aspect will be correct where the left_FID is -1, and to get the aspect when the right_FID is -1 just add 180°. Then based on the original FID you can aggregate, get the majority aspect based on length etc.

The Polygon to line tool is scriptable, (as far as I know) COGO tools are not, so you would have to come up with something there yourself.

Hope this helps!


Calculate Polygon Main Angle (Cartography)

Calculates the dominant angles of input polygon features and assigns the values to a specified field in the feature class

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//007000000028000000.htm


Finding orientation

Within a script, the polygon will be available as a set of rings--one outer ring and zero or more inner rings--with each ring represented by a cyclically ordered tuple of vectors (v[0], v1, ..., v[m-1], v[m] = v[0]). Each vector gives the coordinates of a vertex (with no two successive vertices coinciding). From this it is straightforward, as others have pointed out, to obtain normal vectors (i.e., vectors perpendicular to the edge directions):

n[i] = t(v[i+1] - v[i]).

The "t" operation rotates a vector 90 degrees counterclockwise:

t( (x, y) ) = (y, -x).

Only the directions of these normal vectors matter, so rescale them to have unit length: a vector (x, y) rescales to (x/s, y/s) where s = Sqrt(x^2 + y^2) (which is the length of its corresponding edge). From now on, let's assume this has been done. Write the components of the resulting unit normal vectors as

n[i] = (u[i], v[i]), i = 0, 1, ..., m-1.

Discriminating outside from inside

As you remark, this leaves a directional ambiguity: should we be using n[i] or -n[i]? Which one points outwards? This question is equivalent to finding the degree of the Gauss map. To compute it, you need to sum the angles by which the normal directions change as you march around a ring. Because the normal vectors have unit length, the cosine of the angle between two successive edges is

Cos(q_i) = n[i] . n[i+1] = u[i]*u[i+1] + v[i]*v[i+1], i = 0, 1, ..., m-1.

(Define n[m] = n[0].)

The sine of the angle between two successive edges is

Sin(q_i) = n[i] . t(n[i+1]) = u[i]*v[i+1] - v[i]*u[i+1].

(Note that these calculations require only sums, differences, and products so far.) Applying the principal inverse tangent function (ATan2) to any such (cosine, sine) pair gives the angle q_i between -180 and 180 degrees. Summing these angles for i = 0, 1, ..., n-1 produces (up to floating point error) the total curvature of the ring, which must be a multiple of 360 degrees; for a closed non-self-intersecting ring it wil be either +360 or -360. In the first case the degree is 1 and in the second case the degree is -1. The normals are all outwardly oriented when the degree of the outer ring is +1 and the degrees of the inner rings are -1. Re-orient them ring by ring, as necessary, according to this rule. That is, if the degree of any ring is the opposite of that which is needed, negate all the normals for that ring. Now you can proceed with your insolation calculations.