diff --git a/GsaGH/Helpers/Assembly/Properties/Materials.cs b/GsaGH/Helpers/Assembly/Properties/Materials.cs index 4aa94279f..3eb1e1574 100644 --- a/GsaGH/Helpers/Assembly/Properties/Materials.cs +++ b/GsaGH/Helpers/Assembly/Properties/Materials.cs @@ -124,7 +124,7 @@ private void AddMaterial(GsaMaterial material, ref Prop2D prop2d) { int id = ConvertMaterial(material); // update API prop depending on std material type - if (material is GsaCustomMaterial) { + if (material.MaterialType == MatType.Custom) { prop2d.MaterialGradeProperty = 0; prop2d.MaterialAnalysisProperty = id; } else { @@ -143,7 +143,7 @@ private void AddMaterial(GsaMaterial material, ref Prop3D prop3d) { int id = ConvertMaterial(material); // update API prop depending on std material type - if (material is GsaCustomMaterial) { + if (material.MaterialType == MatType.Custom) { prop3d.MaterialGradeProperty = 0; prop3d.MaterialAnalysisProperty = id; } else { @@ -162,7 +162,7 @@ private void AddMaterial(GsaMaterial material, ref Section section) { int id = ConvertMaterial(material); // update API prop depending on std material type - if (material is GsaCustomMaterial) { + if (material.MaterialType == MatType.Custom) { section.MaterialGradeProperty = 0; section.MaterialAnalysisProperty = id; } else { diff --git a/GsaGH/Parameters/0_Model/GsaMaterials.cs b/GsaGH/Parameters/0_Model/GsaMaterials.cs index 018eefd08..8653afc4a 100644 --- a/GsaGH/Parameters/0_Model/GsaMaterials.cs +++ b/GsaGH/Parameters/0_Model/GsaMaterials.cs @@ -36,47 +36,45 @@ internal GsaMaterial GetMaterial(Prop3D property) { } private GsaMaterial GetMaterial(MaterialType type, int analysisProp, int gradeProp) { - int id = analysisProp; - if (id != 0) { // it is a custom material - if (AnalysisMaterials.ContainsKey(id)) { - return AnalysisMaterials[id]; + if (analysisProp != 0) { // it is a custom material + if (AnalysisMaterials.ContainsKey(analysisProp)) { + return AnalysisMaterials[analysisProp]; } else { - return new GsaReferencedMaterial(id, GsaMaterialFactory.GetMatType(type)); + return new GsaReferencedMaterial(analysisProp, MatType.Custom); } } - id = gradeProp; switch (type) { case MaterialType.ALUMINIUM: - return AluminiumMaterials.TryGetValue(id, out GsaMaterial aluminium) ? aluminium - : new GsaReferencedMaterial(id, MatType.Aluminium); + return AluminiumMaterials.TryGetValue(gradeProp, out GsaMaterial aluminium) ? aluminium + : new GsaReferencedMaterial(gradeProp, MatType.Aluminium); case MaterialType.CONCRETE: - return ConcreteMaterials.TryGetValue(id, out GsaMaterial concrete) ? concrete - : new GsaReferencedMaterial(id, MatType.Concrete); + return ConcreteMaterials.TryGetValue(gradeProp, out GsaMaterial concrete) ? concrete + : new GsaReferencedMaterial(gradeProp, MatType.Concrete); case MaterialType.FABRIC: - return FabricMaterials.TryGetValue(id, out GsaMaterial fabric) ? fabric - : new GsaReferencedMaterial(id, MatType.Fabric); + return FabricMaterials.TryGetValue(gradeProp, out GsaMaterial fabric) ? fabric + : new GsaReferencedMaterial(gradeProp, MatType.Fabric); case MaterialType.FRP: - return FrpMaterials.TryGetValue(id, out GsaMaterial frp) ? frp - : new GsaReferencedMaterial(id, MatType.Frp); + return FrpMaterials.TryGetValue(gradeProp, out GsaMaterial frp) ? frp + : new GsaReferencedMaterial(gradeProp, MatType.Frp); case MaterialType.GLASS: - return GlassMaterials.TryGetValue(id, out GsaMaterial glass) ? glass - : new GsaReferencedMaterial(id, MatType.Glass); + return GlassMaterials.TryGetValue(gradeProp, out GsaMaterial glass) ? glass + : new GsaReferencedMaterial(gradeProp, MatType.Glass); case MaterialType.FIRST: - return SteelMaterials.TryGetValue(id, out GsaMaterial steel) ? steel - : new GsaReferencedMaterial(id, MatType.Steel); + return SteelMaterials.TryGetValue(gradeProp, out GsaMaterial steel) ? steel + : new GsaReferencedMaterial(gradeProp, MatType.Steel); case MaterialType.TIMBER: - return TimberMaterials.TryGetValue(id, out GsaMaterial timber) ? timber - : new GsaReferencedMaterial(id, MatType.Timber); + return TimberMaterials.TryGetValue(gradeProp, out GsaMaterial timber) ? timber + : new GsaReferencedMaterial(gradeProp, MatType.Timber); default: - return new GsaReferencedMaterial(id, GsaMaterialFactory.GetMatType(type)); + return new GsaReferencedMaterial(gradeProp, GsaMaterialFactory.GetMatType(type)); } } diff --git a/GsaGH/Parameters/1_Properties/GsaReferencedMaterial.cs b/GsaGH/Parameters/1_Properties/GsaReferencedMaterial.cs index 271aaec87..e2aea29b9 100644 --- a/GsaGH/Parameters/1_Properties/GsaReferencedMaterial.cs +++ b/GsaGH/Parameters/1_Properties/GsaReferencedMaterial.cs @@ -15,7 +15,7 @@ internal GsaReferencedMaterial(int id, MatType type) { } public override string ToString() { - return $"Custom ID:{Id} (referenced)"; + return $"{MaterialType} ID:{Id} (referenced)"; } } }