Please try the following code (Revit 2016 API) and tell me it works
#region Namespaces using System; using System.Text; using System.Linq; using System.Xml; using System.Reflection; using System.ComponentModel; using System.Collections; using System.Collections.Generic; using System.Windows; using System.Windows.Media.Imaging; using System.Windows.Forms; using System.IO; using Autodesk.Revit.ApplicationServices; using Autodesk.Revit.Attributes; using Autodesk.Revit.DB; using Autodesk.Revit.DB.Events; using Autodesk.Revit.DB.Architecture; using Autodesk.Revit.DB.Structure; using Autodesk.Revit.DB.Mechanical; using Autodesk.Revit.DB.Electrical; using Autodesk.Revit.DB.Plumbing; using Autodesk.Revit.UI; using Autodesk.Revit.UI.Selection; using Autodesk.Revit.UI.Events; //using Autodesk.Revit.Collections; using Autodesk.Revit.Exceptions; using Autodesk.Revit.Utility; using RvtApplication = Autodesk.Revit.ApplicationServices.Application; using RvtDocument = Autodesk.Revit.DB.Document; #endregion namespace RevitAddinCS2 { [Transaction(TransactionMode.Manual)] [Regeneration(RegenerationOption.Manual)] public class ExtCmd : IExternalCommand { #region Cached Variables private static ExternalCommandData _cachedCmdData; public static UIApplication CachedUiApp { get { return _cachedCmdData.Application; } } public static RvtApplication CachedApp { get { return CachedUiApp.Application; } } public static RvtDocument CachedDoc { get { return CachedUiApp.ActiveUIDocument.Document; } } #endregion #region IExternalCommand Members public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elemSet) { _cachedCmdData = cmdData; try { FamilySymbol famSym = new FilteredElementCollector(CachedDoc).OfClass(typeof(FamilySymbol)).Cast<FamilySymbol>().FirstOrDefault(q => q.Family.Name.Contains("BoxGutterVoidSweep")); Reference edgeRef = CachedUiApp.ActiveUIDocument.Selection.PickObject(ObjectType.Edge); RoofBase roof = CachedDoc.GetElement(edgeRef) as RoofBase; Options geoOptions = CachedDoc.Application.Create.NewGeometryOptions(); geoOptions.DetailLevel = ViewDetailLevel.Fine; geoOptions.ComputeReferences = true; GeometryElement geoElem = roof.get_Geometry(geoOptions); Edge edge = roof.GetGeometryObjectFromReference(edgeRef) as Edge; Face face = null; foreach(GeometryObject geomobj in geoElem) { Solid s = geomobj as Solid; foreach(Face f in s.Faces) { foreach(EdgeArray ea in f.EdgeLoops) { if(ea.Cast<Edge>().ToList().Contains(edge)) { face = f; break; } } } } Line line = edge.AsCurveFollowingFace(face)as Line; using (Transaction t = new Transaction(CachedDoc, "void")) { t.Start(); famSym.Activate(); FamilyInstance voidInstance = CachedDoc.Create.NewFamilyInstance(face, line , famSym); t.Commit(); } return Result.Succeeded; } catch (Exception ex) { msg = ex.ToString(); return Result.Failed; } } #endregion } }