Skip to content

Commit

Permalink
fix setting the MaterialAnalysisProperty if MaterialType is custom
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristjan Nielsen committed Oct 9, 2023
1 parent 289d855 commit f13048b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
6 changes: 3 additions & 3 deletions GsaGH/Helpers/Assembly/Properties/Materials.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
40 changes: 19 additions & 21 deletions GsaGH/Parameters/0_Model/GsaMaterials.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down
2 changes: 1 addition & 1 deletion GsaGH/Parameters/1_Properties/GsaReferencedMaterial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal GsaReferencedMaterial(int id, MatType type) {
}

public override string ToString() {
return $"Custom ID:{Id} (referenced)";
return $"{MaterialType} ID:{Id} (referenced)";
}
}
}

0 comments on commit f13048b

Please sign in to comment.