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

Subject: Display analysis results in a Revit model using Dynamic Model Update

Summary: 
On startup, the external application creates a trigger that will execute when walls, masses, and family instances in the project change. When this occurs, Revit calculates the distance from a family instance (sphere.rfa) to several points on each face. These distances are used as values for the analysis visualization display.

Classes: 
Autodesk.Revit.DB.Analysis.FieldDomainPointsByUV
Autodesk.Revit.DB.Analysis.FieldValues
Autodesk.Revit.DB.Analysis.SpatialFieldManager
Autodesk.Revit.DB.BoundingBoxUV
Autodesk.Revit.DB.Events.DocumentOpenedEventArgs
Autodesk.Revit.DB.FaceArray
Autodesk.Revit.DB.FilteredElementCollector
Autodesk.Revit.DB.LocationPoint
Autodesk.Revit.DB.UpdaterRegistry

Project Files:
Command.cs

Description: 
1.	On startup, register a DocumentOpened event. When a document is opened
a.	Check for the presence of the sphere family
b.	Check for the presence of a 3D view named “AVF”
c.	Create a GetChangeTypeGeometry trigger that will activate when a wall, mass, or family instance changes
2.	When this trigger occurs
a.	Find the XYZ location of the sphere
b.	Get the existing spatial field manager object, or create one if one does not already exist
c.	Create a face array containing every face of a wall or mass in the project, including in-place geometry
d.	Calculate the distance between the sphere’s origin and several points on each face
e.	Display these distances as analysis results on the faces by updating the spatial field primitive

Instructions: 
1.	Open DistanceToSurfaces.rvt
2.	Move any wall, mass, or the sphere family instance