Ejemplo n.º 1
0
        /***************************************************/

        public static Autodesk.Revit.DB.Electrical.CableTrayType ToRevitElementType(this oM.MEP.System.SectionProperties.CableTraySectionProperty property, Document document, IEnumerable <BuiltInCategory> categories = null, RevitSettings settings = null, Dictionary <Guid, List <int> > refObjects = null)
        {
            if (property == null || document == null)
            {
                return(null);
            }

            Autodesk.Revit.DB.Electrical.CableTrayType elementType = refObjects.GetValue <Autodesk.Revit.DB.Electrical.CableTrayType>(document, property.BHoM_Guid);
            if (elementType != null)
            {
                return(elementType);
            }

            settings = settings.DefaultIfNull();

            elementType = property.ElementType(document, categories, settings) as Autodesk.Revit.DB.Electrical.CableTrayType;
            if (elementType != null)
            {
                return(elementType);
            }

            List <Autodesk.Revit.DB.Electrical.CableTrayType> trayTypes = new FilteredElementCollector(document).OfClass(typeof(Autodesk.Revit.DB.Electrical.CableTrayType)).Cast <Autodesk.Revit.DB.Electrical.CableTrayType>().ToList();

            if (property.SectionProfile.ElementProfile is BH.oM.Spatial.ShapeProfiles.BoxProfile)
            {
                elementType = trayTypes.FirstOrDefault(x => x.FamilyName == "Cable Tray with Fittings");
            }

            if (elementType != null)
            {
                BH.Engine.Reflection.Compute.RecordNote($"CableTray is being pushed as the first type available in the Revit model, in this case {elementType.Name}.");
            }
            else
            {
                return(null);
            }

            // Copy parameters from BHoM object to Revit element
            elementType.CopyParameters(property, settings);

            refObjects.AddOrReplace(property, elementType);
            return(elementType);
        }