Application: DirectionCalculation
Revit Platform: All
Revit Version: 2011.0
First Released For: 2011.0
Programming Language: C#
Skill Level: Advanced
Category: Geometry
Type: ExternalCommand

Subject: 
Identify orientation of building elements

Summary: 
Find all windows and exterior walls that face the south direction.

Classes: 
Autodesk.Revit.DB.FilteredElementCollector
Autodesk.Revit.DB.Location
Autodesk.Revit.DB.ElementClassFilter
Autodesk.Revit.DB.ElementCategoryFilter
Autodesk.Revit.DB.Transform
Autodesk.Revit.UI.Selection.Selection

Project Files:
FindSouthFacing.cs
FindSouthFacingWalls.cs
FindSouthFacingWindows.cs

Description: 
South Facing Walls 
1.	Find the exterior walls using the wall type’s Function parameter
2.	The vector that describes the wall’s direction is calculated using the wall’s location curve
a.	If the the active project location's north/south direction is being used, transform the wall’s direction vector by the rotation angle of the ActiveProjectLocation.
b.	Otherwise use the default coordinate system's Y-axis which represents the north/south direction
3.	Determine if the wall’s direction vector is “south-facing” by checking if it is within a range of -45 degrees to 45 degrees from the south vector

South Facing Windows
1.	Find all windows (elements that belong to the FamilyInstance class and the OST_Windows built in category
2.	Get the direction of each window. This can be done with the transform of each window instance and the values of the FacingFlipped and HandFlipped properties. Alternatively, the FacingOrientation property can be used.
a.	If the the active project location's north/south direction is being used, transform the window’s direction vector by the rotation angle of the ActiveProjectLocation.
b.	Otherwise use the default coordinate system's Y-axis which represents the north/south direction
3.	Determine if the window’s direction vector is “south-facing” by checking if it is within a range of -45 degrees to 45 degrees from the south vector

Instructions: 
1.	Open FindSouthFacing.rvt
2.	Run external command “South Facing Walls Without ProjectLocation”
3.	The walls that face south (without regard to the project’s location) are selected
4.	Run external command “South Facing Walls With ProjectLocation”
5.	The walls that face south (with regard to the project’s location) are selected
6.	Run external command “South Facing Windows Without ProjectLocation”
7.	The windows that face south (without regard to the project’s location) are selected
8.	Run external command “South Facing Windows With ProjectLocation”
9.	The windows that face south (with regard to the project’s location) are selected