Exemple #1
0
        /// <summary>
        /// Obtain a Family from the current document given it's name
        /// </summary>
        /// <param name="name">The name of the family in the current document</param>
        /// <returns></returns>
        public static Family ByName(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException();
            }

            TransactionManager.Instance.EnsureInTransaction(Document);

            // look up the loaded family
            var fec = new Autodesk.Revit.DB.FilteredElementCollector(Document);

            fec.OfClass(typeof(Autodesk.Revit.DB.Family));

            // obtain the family type with the provided name
            var families = fec.Cast <Autodesk.Revit.DB.Family>();

            var family = families.FirstOrDefault(x => x.Name == name);

            if (family == null)
            {
                throw new Exception(Properties.Resources.FamilySymbolNotFound1);
            }

            TransactionManager.Instance.TransactionTaskDone();

            return(Family.FromExisting(family, true));
        }
Exemple #2
0
 public static Family Wrap(Autodesk.Revit.DB.Family ele, bool isRevitOwned)
 {
     return(Family.FromExisting(ele, isRevitOwned));
 }