Application: PlaceFamilyInstanceByFace
Revit Platform: All
Revit Version: 2011.0
First Released For: 2009.0
Programming Language: C#
Skill Level: Medium
Category: Families
Type: ExternalCommand

Subject: Create family instance on face.
Summary: 
This sample demonstrates how to create family instance on face.

Classes: 
Autodesk.Revit.UI.IExternalCommand
Autodesk.Revit.DB.FamilySymbol 
Autodesk.Revit.DB.FamilyInstance
Autodesk.Revit.DB.Face
Autodesk.Revit.DB.Options
Autodesk.Revit.DB.Solid

Project Files: 
Command.cs
This file contains the class Command which inherits from IExternalCommand interface and implements the Execute method.

FamilyInstanceCreator.cs
This is main data class for creating family Instance by face. It contains all operations in Revit.

PointUserControl.cs
This class defines a user control for specifying point data which contains three text boxes for X, Y and Z coordinates of a point.
 
BasedType.cs
This class contains a dialog which provides two options for user to choose the type to create the family instance. It provides two types - Point-based and Line-based. 

PlaceFamilyInstanceForm.cs
This file contains a dialog which provides options to specify positions and face on which the family instance will be placed.

Description: 
This sample will demonstrate how to create family instance on face.

Instructions: 
1.	Draw some elements with face geometry in current document.
2.	Select an element and execute the command.
3.	Choose a type in the “Based Type” dialog and click “Next” button. 
4.	Specify the face, family symbol and positions information. 
5.	Click “Create” button to create a family instance.

Notes: 
1.	Prepare your Revit project. 
Open or new a Revit project and make sure there are some face-based and point-based family symbols in the project. A sample project file PlaceFamilyInstanceByFace.rvt is available in the sample’s folder.
2.	Currently in API there is no good way to check whether a family symbol is face-based and point-based/line based. User must know clear about the family symbol selected to create a family instance. The sample will skip validating that and just provide message if creation fails. 
3.	The default family symbol is the one provided in this sample.    (Line: “Line-based”; Point: “Point-based”)
4.	The default value of start point is the minimum point of this selected face. The default value of end point is the maximum point of this selected face. 
5.	The default value of location point is the center point in bounding box of the selected face
6.	Please copy the rfa files to the Revit installation folder or load them into current document if you use the DLL of this sample directly in Revit. Nothing to do when you debug this project.