Application: AutoUpdate
Revit Platform: All
Revit Version: 2011.0
First Released For: 2010.0
Programming Language: C#
Skill Level: Medium
Category: Basics
Type: ExternalApplication

Subject: Auto-update Revit model after document is opened.
Summary: 
This sample demonstrates how to subscribe DocumentOpened event and modify model in event handler in the event handler method.

Classes: 
Autodesk.Revit.UI.IExternalApplication
Autodesk.Revit.DB.Events

Project Files: 
ExternalApplication.cs
This file contains a class Application which implements IExternalApplcation interface. The OnStartUp method will register DocumentOpened event when Revit starts. We just demonstrate changing the ProjectInformation.Address property, but user can do other modification for current project, like deleting, creating, etc.

Description: 
The sample implements IExternalApplication interface and provides the following functionalities:
-	There is no UI provided for user, the sample will subscribe event handlers to DocumentOpened event and the string “United States-Massachusetts - Waltham - 610 Lincoln St” will be assigned to ProjectInformation.Address property as the new address.
-	ProjectInformation.Address property can be accessed from the EventArgs.Document property of DocumentOpened event.
-	After modification is finished, the value of the ProjectInformation.Address property will be dumped to the log file.
-	DocumentOpenedEventArgs properties Cancel, Cancellable and Status will be dumped to log when event is raised.

Instructions: 
1.	Run Revit and open a document.
2.	And then, go to Settings à Project Information à Project Address, and then you can see the value of this property is changed into what we assigned. In this sample, we trigger this event from UI, so it must be registered on ControlledApplication.
3.	You can also refer to the log file to check whether the operation is successful.

Note:
Because Family document doesn’t support Project Information, this sample should not run on Family document.