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

Subject: Measure height of skylight window
Summary: 
This sample shows how to find the height of a skylight window above the ground level using the Revit API method FindReferencesByDirection.

Classes: 
Autodesk.Revit.DB.FilteredElementCollector
Autodesk.Revit.DB.FamilyInstance
Autodesk.Revit.DB.ModelCurve
Autodesk.Revit.DB.BoundingBoxXYZ
Autodesk.Revit.DB.Document
Autodesk.Revit.UI.Selection.Selection

Project Files: 
MeasureHeight.cs

Description: 
1.	Find a 3D view to use with FindReferencesByDirection
2.	Check if a roof-hosted window is selected
3.	Calculate the window’s height above a floor (the floor’s ID is hard-coded in this sample)
4.	Use the center of the window’s bounding box as the start point for FindReferencesByDirection
5.	Run FindReferencesByDirection using the negative Z direction
6.	Find the closest reference that belongs to the floor
7.	Create a model curve to show the “ray” found by FindReferencesByDirection

Instructions:
1.	Open MeasureSkylightHeight.rvt
2.	Select the skylight window
3.	Run the external command
4.	A task dialog will report the window’s height and a line is created to show where the distance was measured