title: Place a single instance of a family into a Revit project using a C# plugin
body: <p>I'm trying to create my first Revit plugin. </p>
  
  <p>I'm using Revit 2014 and what I want is to place a SINGLE instance of a family loaded from a file. I'm actually using this code:</p>
  
  <pre><code>[TransactionAttribute(TransactionMode.Manual)]
  [RegenerationAttribute(RegenerationOption.Manual)]
  public class InsertFamily : IExternalCommand
  {
      readonly List&lt;ElementId&gt; _addedElementIds = new List&lt;ElementId&gt;();
  
      public Result Execute(
          ExternalCommandData commandData,
          ref string message,
          ElementSet elements)
      {
          UIApplication uiApp = commandData.Application;
          Document document = uiApp.ActiveUIDocument.Document;
  
          FamilySymbol family = null;
          bool good = false;
          using (var trans = new Transaction(document, "inserting family"))
          {
              trans.Start();
              good = document.LoadFamilySymbol(@"my file path.rfa", "my type", new FamilyLoadingOverwriteOption(), out family);
              trans.Commit();
          }
          if (good &amp;&amp; family != null)
          {
  
              _addedElementIds.Clear();
  
              uiApp.Application.DocumentChanged += applicationOnDocumentChanged;
  
              uiApp.ActiveUIDocument.PromptForFamilyInstancePlacement(family);
  
              uiApp.Application.DocumentChanged -= applicationOnDocumentChanged;
  
          }
          return Result.Succeeded;
      }
  
      private void applicationOnDocumentChanged(object sender, DocumentChangedEventArgs documentChangedEventArgs)
      {
          _addedElementIds.AddRange(documentChangedEventArgs.GetAddedElementIds());        
      }
  }
  
  
  
  class FamilyLoadingOverwriteOption : IFamilyLoadOptions
  {
      public bool OnFamilyFound(bool familyInUse, out bool overwriteParameterValues)
      {
          overwriteParameterValues = true;
          return true;
      }
  
      public bool OnSharedFamilyFound(Family sharedFamily, bool familyInUse, out FamilySource source, out bool overwriteParameterValues)
      {
          source = FamilySource.Family;
          overwriteParameterValues = true;
          return true;
      }
  }
  </code></pre>
  
  <p>The problem is that the method <code>PromptForFamilyInstancePlacement</code> allows user to insert multiple instances of the family. I want that the user can insert only ONE instance into the project. I write also the code to have back the inserted instance (using the <code>DocumentChanged</code> event as you can see), so maybe that handler can be useful in some ways..</p>