Exemple #1
0
        /***************************************************/
        /****               Public Methods              ****/
        /***************************************************/

        public static oM.Physical.Constructions.Construction ConstructionFromRevit(this HostObjAttributes hostObjAttributes, string materialGrade = null, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null)
        {
            settings = settings.DefaultIfNull();

            string refId = hostObjAttributes.Id.ReferenceIdentifier(materialGrade);

            oM.Physical.Constructions.Construction construction = refObjects.GetValue <oM.Physical.Constructions.Construction>(refId);
            if (construction != null)
            {
                return(construction);
            }

            List <BH.oM.Physical.Constructions.Layer> layers = new List <oM.Physical.Constructions.Layer>();
            CompoundStructure compoundStructure = hostObjAttributes.GetCompoundStructure();

            if (compoundStructure != null)
            {
                IEnumerable <CompoundStructureLayer> compoundStructureLayers = compoundStructure.GetLayers();
                if (compoundStructureLayers != null)
                {
                    foreach (CompoundStructureLayer layer in compoundStructureLayers)
                    {
                        layers.Add(layer.Layer(hostObjAttributes, materialGrade, settings, refObjects));
                    }
                }
            }

            construction = BH.Engine.Physical.Create.Construction(hostObjAttributes.FamilyTypeFullName(), layers);

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

            refObjects.AddOrReplace(refId, construction);
            return(construction);
        }