示例#1
0
        /***************************************************/
        /****               Public Methods              ****/
        /***************************************************/

        public static oM.Architecture.Elements.Ceiling CeilingFromRevit(this Autodesk.Revit.DB.Ceiling ceiling, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null)
        {
            if (ceiling == null)
            {
                return(null);
            }

            settings = settings.DefaultIfNull();

            oM.Architecture.Elements.Ceiling bHoMCeiling = refObjects.GetValue <oM.Architecture.Elements.Ceiling>(ceiling.Id);
            if (bHoMCeiling != null)
            {
                return(bHoMCeiling);
            }

            oM.Physical.Constructions.Construction construction = (ceiling.Document.GetElement(ceiling.GetTypeId()) as HostObjAttributes).ConstructionFromRevit(null, settings, refObjects);

            ISurface location = null;
            Dictionary <PlanarSurface, List <PlanarSurface> > surfaces = ceiling.PanelSurfaces(null, settings);

            if (surfaces != null && surfaces.Count != 0)
            {
                List <ISurface> locations = new List <ISurface>();
                foreach (KeyValuePair <PlanarSurface, List <PlanarSurface> > kvp in surfaces)
                {
                    locations.Add(new PlanarSurface(kvp.Key.ExternalBoundary, kvp.Value.Select(x => x.ExternalBoundary).ToList()));
                }

                if (locations.Count == 1)
                {
                    location = locations[0];
                }
                else
                {
                    location = new PolySurface {
                        Surfaces = locations
                    }
                };
            }
            else
            {
                ceiling.NoPanelLocationError();
            }

            bHoMCeiling = new oM.Architecture.Elements.Ceiling {
                Surface = location, Construction = construction
            };
            bHoMCeiling.Name = ceiling.FamilyTypeFullName();

            // Add ceiling patterns
            List <BH.oM.Geometry.Line> ceilingPatterns = new List <BH.oM.Geometry.Line>();

            if (location is PlanarSurface)
            {
                ceilingPatterns.AddRange(ceiling.CeilingPattern(settings, location as PlanarSurface));
            }
            else if (location is PolySurface)
            {
                foreach (ISurface surface in ((PolySurface)location).Surfaces)
                {
                    if (surface is PlanarSurface)
                    {
                        ceilingPatterns.AddRange(ceiling.CeilingPattern(settings, surface as PlanarSurface));
                    }
                }
            }

            if (ceilingPatterns.Count != 0)
            {
                bHoMCeiling.Tiles = BH.Engine.Architecture.Compute.CeilingTiles(bHoMCeiling, ceilingPatterns);
            }

            if (surfaces.Values.Where(x => x != null).Sum(x => x.Count) != 0)
            {
                BH.Engine.Reflection.Compute.RecordWarning("Currently ceiling openings are not taken into account when generating ceilings.");
            }

            //Set identifiers, parameters & custom data
            bHoMCeiling.SetIdentifiers(ceiling);
            bHoMCeiling.CopyParameters(ceiling, settings.ParameterSettings);
            bHoMCeiling.SetProperties(ceiling, settings.ParameterSettings);

            refObjects.AddOrReplace(ceiling.Id, bHoMCeiling);
            return(bHoMCeiling);
        }
示例#2
0
        /***************************************************/
        /****              Public methods               ****/
        /***************************************************/

        public static Ceiling ToRevitCeiling(this oM.Architecture.Elements.Ceiling ceiling, Document document, RevitSettings settings = null)
        {
            BH.Engine.Reflection.Compute.RecordError("Revit API does not allow creation of Ceiling: This is a known limitation, currently, Revit API doesn't support the new ceiling creation.");
            return(null);
        }