Application: RevitCommands
Revit Platform: All
Revit Version: 2010.0
First Released For: 8.0
Last Modified: 02/26/2008
Modified By: AL Autodesk
Programming Language: VB.NET
Skill Level: Beginning
Category: Basics, Families
Type: ExternalCommand

Subject: Simple Revit commands.
Summary: These sample contains 5 commands, demonstrates:
1.	How to load family from family file.
2.	How to load family symbol from family file.
3.	How to access the selection set.
4.	How to get and set library paths in Revit.
5.	How to retrieve data from selected elements.

Classes: 
Autodesk.Revit.Element 
Autodesk.Revit.Parameter
Autodesk.Revit.Document
Autodesk.Revit.Application
Autodesk.Revit.Location
Autodesk.Revit.Parameter
Autodesk.Revit.Geometry.Element
Autodesk.Revit.Geometry.Solid
Autodesk.Revit.Geometry.Instance
Autodesk.Revit.Geometry.Curve
Autodesk.Revit.Geometry.Mesh

Project Files: 
LoadFamily.vb
This file contains two command classes RvtCmd_LoadFamily which loads a family of the given family name and RvtCmd_LoadFamilySymbol which loads a family symbol/type of the given file and symbol name.

Selection.vb
This file contains the command Selection which shows the access to the current selection set that displays the number of selected elements and some simple information of these elements such as name, category and so on.

LibraryPath.vb
This file contains the command LibraryPath which goes through the list of library paths held in the Revit. If it has a certain key, it erases it.  If not, it adds a new path to the existing set. In the Revit UI, you can check the list in: Settings --> Options... --> [File Locations] Tab --> Libraries.

RvtUtils.vb
This file contains the class RvtUtils which is used within the command ShowElementData, RvtUtils has a collection of functions such as GeometryElementToString() that can retrieve data from the selected elements and convert them to strings.

ShowElementData.vb
This file contains the command ShowElementData which will display the information such as parameters, locations and geometries of selected elements using the utility class RvtUtils.

Description: 
5 commands:
-	Load Family: loads a family of the given family name.
-	Load Family Symbol: loads a family symbol/type of the given file and symbol name.
-	Selection: shows the access to the current selection set.
-	Library Path: goes through the list of library paths held in the Revit. 
If it has a certain key, it erases it.  If not, it adds a new path to the existing set. 
In the Revit UI, you could check the list in: 
Settings --> Options... --> [File Locations] Tab --> Libraries.
-	Show Element Data: displays a geometry, location, and parameter data of selected elements.

Codes implementation instructions:
-	To load family, use Document.LoadFamily(string rfaPath).
-	To load family symbol, use Document.LoadFamilySymbol(string filename, string name), filename is the file that contains the family symbol and the parameter name is the symbol name.
-	To get the selected element collection, use Document.Selection.Elements.
-	To get or set the library paths, use Application.Options.LibraryPaths.
-	To get the location of an element, use Element.Location
-	To get the geometry object of an element, use Element.Geometry(Autodesk.Revit.Geometry.Options options), the parameter options can be created by Application.Create.NewGeometryOptions()
-	Use Autodesk.Revit.Geometry.Element.Objects to get the GeometryObjectArray, and then convert the objects in it to Solid, Instance, Curve, Mesh etc.

Instructions: 
1.	Prepare. Make sure there is a family file “W-Wide Flange-Column.rfa” with a type named “W10X33” in current folder.
2.	Run the command (for Load Family, Load Family Symbol, Library Path)
or
Select some elements and then run the command (for Selection, Show Element Data)