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

Subject: Divided surface panel measurement 

Summary: 
Measure the distance from a selected object to all divided surface panels. Store this value for each panel in an instance parameter Distance.

Classes: 
	Autodesk.Revit.UI.IExternalCommand
	Autodesk.Revit.DB.DividedSurface
	Autodesk.Revit.DB.Panel

Project Files:

Command.cs
	This file contains the SetDistanceParam class and is invoked by the external command. This class is used to compute the distance data and update the parameter.

Description: 
1.	Find divided surfaces in the massing family
2.	Find all panels in the DividedSurface elements. The panels are FamilyInstance elements returned by the DividedSurface.GetTileFamilyInstance(GridNode, tileIndex) method.
3.	Find the location of the selected "origin" component.
4.	Check the parameters of each panel and set the "Distance" instance parameter with the distance from that panel to the origin component.

Instructions: 
1.	Open a massing family with divided surfaces such as DistanceToPanels.rfa
2.	The divided surfaces should use a panel with a Distance instance parameter.
3.	The massing family should include a family instance that will be used as the origin for the distance computation.
4.	Select the instance mentioned in step 3) and run this command
5.	The Distance parameter will be populated for each panel. This parameter can be scheduled in the project environment and used to drive the geometry of the panels.