Beispiel #1
0
        public static AbstractFamilyInstance Wrap(Autodesk.Revit.DB.FamilyInstance ele, bool isRevitOwned)
        {
            if (AdaptiveComponentInstanceUtils.HasAdaptiveFamilySymbol(ele))
            {
                return(AdaptiveComponent.FromExisting(ele, isRevitOwned));
            }

            if (ele.StructuralType != Autodesk.Revit.DB.Structure.StructuralType.NonStructural)
            {
                return(StructuralFraming.FromExisting(ele, isRevitOwned));
            }

            return(FamilyInstance.FromExisting(ele, isRevitOwned));
        }
        /// <summary>
        /// Construct from an existing instance of an AdaptiveComponent.
        /// </summary>
        /// <param name="familyInstance"></param>
        /// <param name="isRevitOwned"></param>
        /// <returns></returns>
        internal static AdaptiveComponent FromExisting(Autodesk.Revit.DB.FamilyInstance familyInstance, bool isRevitOwned)
        {
            if (familyInstance == null)
            {
                throw new ArgumentNullException("familyInstance");
            }

            // Not all family instances are adaptive components
            if (!AdaptiveComponentInstanceUtils.HasAdaptiveFamilySymbol(familyInstance))
            {
                throw new Exception("The FamilyInstance is not an adaptive component");
            }

            return(new AdaptiveComponent(familyInstance)
            {
                IsRevitOwned = isRevitOwned
            });
        }