public static BHC.Layer ToBHoM(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); }
public static BHX.Material ToGBXML(this BHC.Layer layer) { 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, 3).ToString(); IEnvironmentMaterial envMaterial = layer.Material.Properties.Where(x => x is IEnvironmentMaterial).FirstOrDefault() as IEnvironmentMaterial; if (envMaterial != null) { gbMaterial.Density.Value = Math.Round(envMaterial.Density, 3).ToString(); gbMaterial.Conductivity.Value = Math.Round(envMaterial.Conductivity, 3).ToString(); gbMaterial.SpecificHeat.Value = envMaterial.SpecificHeat.ToString(); } return(gbMaterial); }