public static bool HasView(global::Revit.Elements.Level level) { Document doc = DocumentManager.Instance.CurrentDBDocument; FilteredElementCollector fec = new FilteredElementCollector(doc); //nested this in a try catch because I want false if this fails for any reason, instead of nulls. try { return(fec.OfClass(typeof(ViewPlan)) .Cast <ViewPlan>().Where(v => !v.IsTemplate).Any(v => v.GenLevel.Id.IntegerValue.Equals(level.Id))); } catch (Exception) { return(false); } }
/// <summary> /// New Family Instance by Curve /// </summary> /// <param name="familyType">Family Type to be applied to new Family Instance.</param> /// <param name="line">Line to place Family Instance at.</param> /// <param name="level">Level to associate Family Instance with.</param> /// <returns>New Family Instance.</returns> public static FamilyInstance ByLine(global::Revit.Elements.FamilyType familyType, Line line, global::Revit.Elements.Level level) { if (familyType == null) { throw new ArgumentNullException(nameof(familyType)); } var symbol = familyType.InternalElement as Autodesk.Revit.DB.FamilySymbol; var locationLine = line.ToRevitType() as Autodesk.Revit.DB.Line; var hostLevel = level.InternalElement as Autodesk.Revit.DB.Level; return(new FamilyInstance(symbol, locationLine, hostLevel)); }