Пример #1
0
        public static BHC.Layer FromGBXML(this BHX.Material gbMaterial)
        {
            BHC.Layer     layer = new BHC.Layer();
            SolidMaterial materialProperties = new SolidMaterial();

            try
            {
                layer.Thickness = System.Convert.ToDouble(gbMaterial.Thickness.Value);
                materialProperties.Conductivity = System.Convert.ToDouble(gbMaterial.Conductivity.Value);
                materialProperties.SpecificHeat = System.Convert.ToDouble(gbMaterial.SpecificHeat.Value);
                materialProperties.Density      = System.Convert.ToDouble(gbMaterial.Density.Value);
            }
            catch { }

            BHM.Material material = new BHM.Material();
            material.Name = gbMaterial.Name;

            material.Properties.Add(materialProperties);
            layer.Material = material;

            return(layer);
        }
Пример #2
0
        public static BHX.Material ToGBXML(this BHC.Layer layer, GBXMLSettings settings)
        {
            BHX.Material gbMaterial = new BHX.Material();

            //double rValue = Math.Round(layer.RValue(), 3);
            //if (double.IsInfinity(rValue) || double.IsNaN(rValue)) rValue = -1; //Error

            gbMaterial.ID   = "material-" + layer.Material.Name.CleanName();
            gbMaterial.Name = layer.Material.Name;
            //gbMaterial.RValue.Value = rValue.ToString();
            gbMaterial.Thickness.Value = Math.Round(layer.Thickness, settings.RoundingSettings.LayerThickness).ToString();

            IEnvironmentMaterial envMaterial = layer.Material.Properties.Where(x => x is IEnvironmentMaterial).FirstOrDefault() as IEnvironmentMaterial;

            if (envMaterial != null)
            {
                gbMaterial.Density.Value      = Math.Round(envMaterial.Density, settings.RoundingSettings.MaterialDensity).ToString();
                gbMaterial.Conductivity.Value = Math.Round(envMaterial.Conductivity, settings.RoundingSettings.MaterialConductivity).ToString();
                gbMaterial.SpecificHeat.Value = envMaterial.SpecificHeat.ToString();
            }

            return(gbMaterial);
        }