Application: PhaseSample
Revit Platform: All
Revit Version: 2009.0
First Released For: 9.0
Last Modified: 02/26/2008
Modified By: AL Autodesk
Programming Language: VB.NET
Skill Level: Beginning
Category: Mechanism (phase)
Type: ExternalCommand

Subject: Filter elements by their phases.
Summary: 
This sample demonstrates how to use phase to filter elements and how to highlight filtered elements by Execute method parameters.

Classes: 
Autodesk.Revit.Document 
Autodesk.Revit.Element 
Autodesk.Revit.Elements.Phase 
Autodesk.Revit.IExternalCommand
Autodesk.Revit.ElementSet

Project Files: 
Command.vb
This file contains the class Command which inherits from IExternalCommand. The function of it is to retrieve all the phases which belong to the current document, and then put them in a dialog with which user could select their phases to determine which elements will be highlighted.

PickPhase.vb
This file contains a Form class, which takes the conditions to filter the elements, user could select a phase property “Created” or “Demolished” with radio buttons then in a list box choose the phases names of elements that to be highlighted after the “OK” button was clicked.

Description: 
-	To get all the phases in a document, use Document.Phases.
-	To get “Created” and “Demolished” phase of an element, use Element.PhaseCreated and Element.PhaseDemolished.
-	To get name of phase object, use Phase.Name.
-	To add an element in a set of element, use Autodesk.Revit.ElementSet.Insert(Element).
-	When the command returns cancelled or failed, a message will be shown and some elements will be highlighted. The message and collection of the elements which can be changed in the method IExternalCommand.Execute are the parameters of the method.

Instructions: 
1.	Prepare your Revit project. Draw something in your document i.e. walls, floors, and change phases for them. A sample project file PhaseSample.rvt is available in the sample’s folder.
2.	Run the command.
3.	Select a phase property “Created” or “Demolished” to filter elements.
4.	In the list box, select the phase names of elements that to be highlighted.