From 10f8cc25723b03c8e11d02eb18d4159975f36fda Mon Sep 17 00:00:00 2001 From: Peter Nugent Date: Sat, 1 Jul 2023 15:08:23 +0100 Subject: [PATCH 1/9] Add "9.4.0" cases where needed and restructure default switch statements --- .../ToBHoM/Properties/ToConstraint6DOF.cs | 47 ++++++++----------- .../ToBHoM/Properties/ToSurfaceProperty.cs | 22 ++++----- .../Loads/FromAreaUniformlyDistributedLoad.cs | 1 + .../ToMidasCivil/Loads/FromLoadCombination.cs | 13 ++--- .../ToMidasCivil/Loads/FromPointForce.cs | 3 +- .../ToMidasCivil/Properties/FromSpring.cs | 23 ++++----- .../Properties/FromSurfaceProperty.cs | 18 ++++--- .../PrivateHelpers/GetPropertyAssignments.cs | 28 +++++------ 8 files changed, 67 insertions(+), 88 deletions(-) diff --git a/MidasCivil_Adapter/Convert/ToBHoM/Properties/ToConstraint6DOF.cs b/MidasCivil_Adapter/Convert/ToBHoM/Properties/ToConstraint6DOF.cs index 9f7b0d1d..85107ae3 100644 --- a/MidasCivil_Adapter/Convert/ToBHoM/Properties/ToConstraint6DOF.cs +++ b/MidasCivil_Adapter/Convert/ToBHoM/Properties/ToConstraint6DOF.cs @@ -73,31 +73,28 @@ public static Constraint6DOF ToConstraint6DOF(this string support, string versio { switch (version) { - case "9.1.0": - case "9.0.5": - case "9.0.0": - case "8.9.5": - case "8.9.0": - case "8.8.5": + case "8.6.5": + case "8.7.5": + case "8.8.1": for (int i = 2; i < 8; i++) { - if (delimitted[i].Trim() == "YES") + if (delimitted[i] == "") { - fixity.Add(true); + fixity.Add(false); stiffness.Add(0); } - else if (delimitted[i].Trim() == "NO") + else { double spring; if (i < 5) { - spring = double.Parse(delimitted[i + 6]).ForcePerLengthToSI(forceUnit, lengthUnit); + spring = double.Parse(delimitted[i]).ForcePerLengthToSI(forceUnit, lengthUnit); } else { - spring = double.Parse(delimitted[i + 6]).MomentToSI(forceUnit, lengthUnit); + spring = double.Parse(delimitted[i]).MomentToSI(forceUnit, lengthUnit); } - if (spring > 1E+017.ForcePerLengthToSI(forceUnit, lengthUnit) || spring > 1E+19.MomentToSI(forceUnit, lengthUnit)) + if (spring > 1E+017.ForcePerLengthFromSI(forceUnit, lengthUnit) || spring > 1E+19.MomentFromSI(forceUnit, lengthUnit)) { fixity.Add(true); stiffness.Add(0); @@ -109,35 +106,32 @@ public static Constraint6DOF ToConstraint6DOF(this string support, string versio } } } - supportName = delimitted[21].Trim(); + supportName = delimitted[15].Trim(); if (supportName == "") { - supportName = "Fx=" + delimitted[8] + "Fy=" + delimitted[9] + "Fz=" + delimitted[10] + "Rx=" + delimitted[11] + "Ry=" + delimitted[12] + "Rz=" + delimitted[13]; + supportName = "Fx=" + delimitted[2] + "Fy=" + delimitted[3] + "Fz=" + delimitted[4] + "Rx=" + delimitted[5] + "Ry=" + delimitted[6] + "Rz=" + delimitted[7]; } - - break; - default: for (int i = 2; i < 8; i++) { - if (delimitted[i] == "") + if (delimitted[i].Trim() == "YES") { - fixity.Add(false); + fixity.Add(true); stiffness.Add(0); } - else + else if (delimitted[i].Trim() == "NO") { double spring; if (i < 5) { - spring = double.Parse(delimitted[i]).ForcePerLengthToSI(forceUnit, lengthUnit); + spring = double.Parse(delimitted[i + 6]).ForcePerLengthToSI(forceUnit, lengthUnit); } else { - spring = double.Parse(delimitted[i]).MomentToSI(forceUnit, lengthUnit); + spring = double.Parse(delimitted[i + 6]).MomentToSI(forceUnit, lengthUnit); } - if (spring > 1E+017.ForcePerLengthFromSI(forceUnit, lengthUnit) || spring > 1E+19.MomentFromSI(forceUnit, lengthUnit)) + if (spring > 1E+017.ForcePerLengthToSI(forceUnit, lengthUnit) || spring > 1E+19.MomentToSI(forceUnit, lengthUnit)) { fixity.Add(true); stiffness.Add(0); @@ -149,16 +143,13 @@ public static Constraint6DOF ToConstraint6DOF(this string support, string versio } } } - supportName = delimitted[15].Trim(); + supportName = delimitted[21].Trim(); if (supportName == "") { - supportName = "Fx=" + delimitted[2] + "Fy=" + delimitted[3] + "Fz=" + delimitted[4] + "Rx=" + delimitted[5] + "Ry=" + delimitted[6] + "Rz=" + delimitted[7]; + supportName = "Fx=" + delimitted[8] + "Fy=" + delimitted[9] + "Fz=" + delimitted[10] + "Rx=" + delimitted[11] + "Ry=" + delimitted[12] + "Rz=" + delimitted[13]; } break; } - - - } } diff --git a/MidasCivil_Adapter/Convert/ToBHoM/Properties/ToSurfaceProperty.cs b/MidasCivil_Adapter/Convert/ToBHoM/Properties/ToSurfaceProperty.cs index 963d7b89..3cf14502 100644 --- a/MidasCivil_Adapter/Convert/ToBHoM/Properties/ToSurfaceProperty.cs +++ b/MidasCivil_Adapter/Convert/ToBHoM/Properties/ToSurfaceProperty.cs @@ -40,29 +40,27 @@ public static ISurfaceProperty ToSurfaceProperty(this string surfaceProperty, st switch (version) { - case "9.1.0": - case "9.0.5": - case "9.0.0": - case "8.9.5": - case "8.9.0": + case "8.8.5": constantThickness = new ConstantThickness { Thickness = System.Convert.ToDouble(split[4].Trim()).LengthToSI(lengthUnit), - Name = "t = " + split[4].Trim() + Name = split[1] }; break; - case "8.8.5": - constantThickness =new ConstantThickness + case "8.8.1": + case "8.7.5": + case "8.6.5": + constantThickness = new ConstantThickness { - Thickness = System.Convert.ToDouble(split[4].Trim()).LengthToSI(lengthUnit), - Name = split[1] + Thickness = System.Convert.ToDouble(split[3].Trim()).LengthToSI(lengthUnit), + Name = "t = " + split[3].Trim() }; break; default: constantThickness = new ConstantThickness { - Thickness = System.Convert.ToDouble(split[3].Trim()).LengthToSI(lengthUnit), - Name = "t = " + split[3].Trim() + Thickness = System.Convert.ToDouble(split[4].Trim()).LengthToSI(lengthUnit), + Name = "t = " + split[4].Trim() }; break; } diff --git a/MidasCivil_Adapter/Convert/ToMidasCivil/Loads/FromAreaUniformlyDistributedLoad.cs b/MidasCivil_Adapter/Convert/ToMidasCivil/Loads/FromAreaUniformlyDistributedLoad.cs index e4051a83..3bfc8688 100644 --- a/MidasCivil_Adapter/Convert/ToMidasCivil/Loads/FromAreaUniformlyDistributedLoad.cs +++ b/MidasCivil_Adapter/Convert/ToMidasCivil/Loads/FromAreaUniformlyDistributedLoad.cs @@ -44,6 +44,7 @@ public static string FromAreaUniformlyDistributedLoad(this AreaUniformlyDistribu switch (version) { + case "9.4.0": case "9.1.0": midasFEMeshLoad = assignedFEMesh + ", PRES, PLATE, FACE, " + FromLoadAxis(femeshLoad.Axis) + direction + ", 0, 0, 0, " + FromLoadProjection(femeshLoad.Projected) + ", " + diff --git a/MidasCivil_Adapter/Convert/ToMidasCivil/Loads/FromLoadCombination.cs b/MidasCivil_Adapter/Convert/ToMidasCivil/Loads/FromLoadCombination.cs index 9204120a..ebabca07 100644 --- a/MidasCivil_Adapter/Convert/ToMidasCivil/Loads/FromLoadCombination.cs +++ b/MidasCivil_Adapter/Convert/ToMidasCivil/Loads/FromLoadCombination.cs @@ -39,16 +39,13 @@ public static List FromLoadCombination(this LoadCombination loadCombinat switch (version) { - case "9.1.0": - case "9.0.5": - case "9.0.0": - case "8.9.5": - case "8.9.0": - case "8.8.5": - line1 = "NAME=" + loadCombination.Name + ", GEN, ACTIVE, 0, 0, , 0, 0, 0"; + case "8.8.1": + case "8.7.5": + case "8.6.5": + line1 = "NAME=" + loadCombination.Name + ", GEN, ACTIVE, 0, 0, , 0, 0"; break; default: - line1 = "NAME=" + loadCombination.Name + ", GEN, ACTIVE, 0, 0, , 0, 0"; + line1 = "NAME=" + loadCombination.Name + ", GEN, ACTIVE, 0, 0, , 0, 0, 0"; break; } diff --git a/MidasCivil_Adapter/Convert/ToMidasCivil/Loads/FromPointForce.cs b/MidasCivil_Adapter/Convert/ToMidasCivil/Loads/FromPointForce.cs index 5d673cd2..fdffd85d 100644 --- a/MidasCivil_Adapter/Convert/ToMidasCivil/Loads/FromPointForce.cs +++ b/MidasCivil_Adapter/Convert/ToMidasCivil/Loads/FromPointForce.cs @@ -35,8 +35,9 @@ public static string FromPointLoad(this PointLoad pointLoad, string assignedNode { string midasPointLoad = ""; - switch(version) + switch (version) { + case "9.4.0": case "9.1.0": midasPointLoad = assignedNode + "," + pointLoad.Force.X.ForceFromSI(forceUnit).ToString() + "," + pointLoad.Force.Y.ForceFromSI(forceUnit).ToString() + diff --git a/MidasCivil_Adapter/Convert/ToMidasCivil/Properties/FromSpring.cs b/MidasCivil_Adapter/Convert/ToMidasCivil/Properties/FromSpring.cs index 9b8e039b..bbd71390 100644 --- a/MidasCivil_Adapter/Convert/ToMidasCivil/Properties/FromSpring.cs +++ b/MidasCivil_Adapter/Convert/ToMidasCivil/Properties/FromSpring.cs @@ -43,28 +43,25 @@ public static string FromSpring(this Constraint6DOF constraint6DOF, string versi switch (version) { - case "9.1.0": - case "9.0.5": - case "9.0.0": - case "8.9.5": - case "8.9.0": - case "8.8.5": - string springFixity = SpringFixity(constraint6DOF, groupCharacterLimit); + case "8.8.1": + case "8.7.5": + case "8.6.5": midasSpring = ( - " " + "," + "LINEAR" + "," + springFixity + + " " + "," + "LINEAR" + "," + stiffness[0].ForcePerLengthFromSI(forceUnit, lengthUnit) + "," + stiffness[1].ForcePerLengthFromSI(forceUnit, lengthUnit) + "," + stiffness[2].ForcePerLengthFromSI(forceUnit, lengthUnit) + "," + stiffness[3].MomentFromSI(forceUnit, lengthUnit) + "," + stiffness[4].MomentFromSI(forceUnit, lengthUnit) + "," + stiffness[5].MomentFromSI(forceUnit, lengthUnit) - + "," + "NO, 0, 0, 0, 0, 0, 0," + new string(constraint6DOF.DescriptionOrName().Replace(",","").Take(groupCharacterLimit).ToArray()) + "," + "0, 0, 0, 0, 0" + + "," + "NO, 0, 0, 0, 0, 0, 0," + new string(constraint6DOF.DescriptionOrName().Replace(",", "").Take(groupCharacterLimit).ToArray()) + "," + "0, 0, 0, 0, 0" ); break; default: + string springFixity = SpringFixity(constraint6DOF, groupCharacterLimit); midasSpring = ( - " " + "," + "LINEAR" + "," + + " " + "," + "LINEAR" + "," + springFixity + stiffness[0].ForcePerLengthFromSI(forceUnit, lengthUnit) + "," + stiffness[1].ForcePerLengthFromSI(forceUnit, lengthUnit) + "," + stiffness[2].ForcePerLengthFromSI(forceUnit, lengthUnit) + "," + stiffness[3].MomentFromSI(forceUnit, lengthUnit) + "," + stiffness[4].MomentFromSI(forceUnit, lengthUnit) + "," + stiffness[5].MomentFromSI(forceUnit, lengthUnit) - + "," + "NO, 0, 0, 0, 0, 0, 0," + new string(constraint6DOF.DescriptionOrName().Replace(",","").Take(groupCharacterLimit).ToArray()) + "," + "0, 0, 0, 0, 0" + + "," + "NO, 0, 0, 0, 0, 0, 0," + new string(constraint6DOF.DescriptionOrName().Replace(",", "").Take(groupCharacterLimit).ToArray()) + "," + "0, 0, 0, 0, 0" ); break; } @@ -98,7 +95,7 @@ private static List SpringStiffness(Constraint6DOF constraint6DOF, strin { if (i < 3) { - stiffness.Add(ForcePerLengthFromSI(1E17,forceUnit, lengthUnit)); + stiffness.Add(ForcePerLengthFromSI(1E17, forceUnit, lengthUnit)); if (!(springs[i] == ForcePerLengthFromSI(1E17, forceUnit, lengthUnit))) Engine.Base.Compute.RecordWarning( DOFType.Fixed + " used, this will overwrite the spring stiffness with 1E+17 N/m"); @@ -141,7 +138,7 @@ private static string SpringFixity(Constraint6DOF constraint6DOF, int groupChara if (!(MidasCivilAdapter.GetSupportedDOFType(freedom))) { Engine.Base.Compute.RecordWarning( - "Unsupported DOFType in " + new string(constraint6DOF.DescriptionOrName().Replace(",","").Take(groupCharacterLimit).ToArray()) + " assumed to be" + DOFType.Fixed); + "Unsupported DOFType in " + new string(constraint6DOF.DescriptionOrName().Replace(",", "").Take(groupCharacterLimit).ToArray()) + " assumed to be" + DOFType.Fixed); support = support + "YES,"; } diff --git a/MidasCivil_Adapter/Convert/ToMidasCivil/Properties/FromSurfaceProperty.cs b/MidasCivil_Adapter/Convert/ToMidasCivil/Properties/FromSurfaceProperty.cs index 1e29dba2..f16ed2fc 100644 --- a/MidasCivil_Adapter/Convert/ToMidasCivil/Properties/FromSurfaceProperty.cs +++ b/MidasCivil_Adapter/Convert/ToMidasCivil/Properties/FromSurfaceProperty.cs @@ -57,25 +57,23 @@ private static string CreateSurfaceProfile(ConstantThickness bhomSurfaceProperty string midasSurfaceProperty = ""; switch (version) { - case "9.1.0": - case "9.0.5": - case "9.0.0": - case "8.9.5": - case "8.9.0": - midasSurfaceProperty = - bhomSurfaceProperty.AdapterId(typeof(MidasCivilId)) + ",VALUE,1,Yes," + - bhomSurfaceProperty.Thickness.LengthFromSI(lengthUnit) + ",0,No,0,0"; - break; case "8.8.5": midasSurfaceProperty = bhomSurfaceProperty.AdapterId(typeof(MidasCivilId)) + "," + new string(bhomSurfaceProperty.DescriptionOrName().Replace(",", "").Take(groupCharacterLimit).ToArray()) + ",VALUE,Yes," + bhomSurfaceProperty.Thickness.LengthFromSI(lengthUnit) + ",0,No,0,0"; break; - default: + case "8.8.1": + case "8.7.5": + case "8.6.5": midasSurfaceProperty = bhomSurfaceProperty.AdapterId(typeof(MidasCivilId)) + ",VALUE,Yes," + bhomSurfaceProperty.Thickness.LengthFromSI(lengthUnit) + ",0,No,0,0"; break; + default: + midasSurfaceProperty = + bhomSurfaceProperty.AdapterId(typeof(MidasCivilId)) + ",VALUE,1,Yes," + + bhomSurfaceProperty.Thickness.LengthFromSI(lengthUnit) + ",0,No,0,0"; + break; } return midasSurfaceProperty; diff --git a/MidasCivil_Adapter/PrivateHelpers/GetPropertyAssignments.cs b/MidasCivil_Adapter/PrivateHelpers/GetPropertyAssignments.cs index 1395e82b..12ad0d6b 100644 --- a/MidasCivil_Adapter/PrivateHelpers/GetPropertyAssignments.cs +++ b/MidasCivil_Adapter/PrivateHelpers/GetPropertyAssignments.cs @@ -67,32 +67,28 @@ private Dictionary> GetPropertyAssignments(string section, str case "SPRING": switch (m_midasCivilVersion) { - case "9.1.0": - case "9.0.5": - case "9.0.0": - case "8.9.5": - case "8.9.0": - case "8.8.5": - if (splitSection[21] == "") + case "8.8.1": + case "8.7.5": + case "8.6.5": + if (splitSection[15] == "") { - string name = "Fx=" + splitSection[8] + "Fy=" + splitSection[9] + "Fz=" + splitSection[10] + "Rx=" + splitSection[11] + - "Ry=" + splitSection[12] + "Rz=" + splitSection[13]; + string name = "Fx=" + splitSection[2] + "Fy=" + splitSection[3] + "Fz=" + splitSection[4] + "Rx=" + splitSection[5] + + "Ry=" + splitSection[6] + "Rz=" + splitSection[7]; propertyAssignments.Add(name, propertyAssignment); } - else - propertyAssignments.Add(splitSection[21], propertyAssignment); - + propertyAssignments.Add(splitSection[15], propertyAssignment); break; default: - if (splitSection[15] == "") + if (splitSection[21] == "") { - string name = "Fx=" + splitSection[2] + "Fy=" + splitSection[3] + "Fz=" + splitSection[4] + "Rx=" + splitSection[5] + - "Ry=" + splitSection[6] + "Rz=" + splitSection[7]; + string name = "Fx=" + splitSection[8] + "Fy=" + splitSection[9] + "Fz=" + splitSection[10] + "Rx=" + splitSection[11] + + "Ry=" + splitSection[12] + "Rz=" + splitSection[13]; propertyAssignments.Add(name, propertyAssignment); } + else - propertyAssignments.Add(splitSection[15], propertyAssignment); + propertyAssignments.Add(splitSection[21], propertyAssignment); break; } break; From a2695ed55fe1efcc387d71be664bc1b66b3d31ec Mon Sep 17 00:00:00 2001 From: Peter Nugent Date: Sat, 1 Jul 2023 15:14:45 +0100 Subject: [PATCH 2/9] Added case for "8.7.0" version of Midas --- MidasCivil_Adapter/Convert/ToBHoM/Properties/ToConstraint6DOF.cs | 1 + .../Convert/ToBHoM/Properties/ToSurfaceProperty.cs | 1 + .../Convert/ToMidasCivil/Properties/FromSurfaceProperty.cs | 1 + MidasCivil_Adapter/PrivateHelpers/GetPropertyAssignments.cs | 1 + 4 files changed, 4 insertions(+) diff --git a/MidasCivil_Adapter/Convert/ToBHoM/Properties/ToConstraint6DOF.cs b/MidasCivil_Adapter/Convert/ToBHoM/Properties/ToConstraint6DOF.cs index 85107ae3..aad14a22 100644 --- a/MidasCivil_Adapter/Convert/ToBHoM/Properties/ToConstraint6DOF.cs +++ b/MidasCivil_Adapter/Convert/ToBHoM/Properties/ToConstraint6DOF.cs @@ -74,6 +74,7 @@ public static Constraint6DOF ToConstraint6DOF(this string support, string versio switch (version) { case "8.6.5": + case "8.7.0": case "8.7.5": case "8.8.1": for (int i = 2; i < 8; i++) diff --git a/MidasCivil_Adapter/Convert/ToBHoM/Properties/ToSurfaceProperty.cs b/MidasCivil_Adapter/Convert/ToBHoM/Properties/ToSurfaceProperty.cs index 3cf14502..fab02025 100644 --- a/MidasCivil_Adapter/Convert/ToBHoM/Properties/ToSurfaceProperty.cs +++ b/MidasCivil_Adapter/Convert/ToBHoM/Properties/ToSurfaceProperty.cs @@ -49,6 +49,7 @@ public static ISurfaceProperty ToSurfaceProperty(this string surfaceProperty, st break; case "8.8.1": case "8.7.5": + case "8.7.0": case "8.6.5": constantThickness = new ConstantThickness { diff --git a/MidasCivil_Adapter/Convert/ToMidasCivil/Properties/FromSurfaceProperty.cs b/MidasCivil_Adapter/Convert/ToMidasCivil/Properties/FromSurfaceProperty.cs index f16ed2fc..218a81ae 100644 --- a/MidasCivil_Adapter/Convert/ToMidasCivil/Properties/FromSurfaceProperty.cs +++ b/MidasCivil_Adapter/Convert/ToMidasCivil/Properties/FromSurfaceProperty.cs @@ -64,6 +64,7 @@ private static string CreateSurfaceProfile(ConstantThickness bhomSurfaceProperty break; case "8.8.1": case "8.7.5": + case "8.7.0": case "8.6.5": midasSurfaceProperty = bhomSurfaceProperty.AdapterId(typeof(MidasCivilId)) + ",VALUE,Yes," + diff --git a/MidasCivil_Adapter/PrivateHelpers/GetPropertyAssignments.cs b/MidasCivil_Adapter/PrivateHelpers/GetPropertyAssignments.cs index 12ad0d6b..bc698223 100644 --- a/MidasCivil_Adapter/PrivateHelpers/GetPropertyAssignments.cs +++ b/MidasCivil_Adapter/PrivateHelpers/GetPropertyAssignments.cs @@ -69,6 +69,7 @@ private Dictionary> GetPropertyAssignments(string section, str { case "8.8.1": case "8.7.5": + case "8.7.0": case "8.6.5": if (splitSection[15] == "") { From 2993b6e517eaf1b5e8e7fb224846ee1faa2bd678 Mon Sep 17 00:00:00 2001 From: Peter Nugent Date: Sat, 1 Jul 2023 20:34:33 +0100 Subject: [PATCH 3/9] Added fix for Rigid Links --- .../CRUD/Create/Elements/RigidLink.cs | 2 +- .../CRUD/Read/Elements/RigidLinks.cs | 2 +- .../Convert/ToBHoM/Elements/ToRigidLink.cs | 54 +++++++++++++------ .../ToMidasCivil/Elements/FromRigidLink.cs | 14 ++++- 4 files changed, 53 insertions(+), 19 deletions(-) diff --git a/MidasCivil_Adapter/CRUD/Create/Elements/RigidLink.cs b/MidasCivil_Adapter/CRUD/Create/Elements/RigidLink.cs index b42670df..3617125f 100644 --- a/MidasCivil_Adapter/CRUD/Create/Elements/RigidLink.cs +++ b/MidasCivil_Adapter/CRUD/Create/Elements/RigidLink.cs @@ -42,7 +42,7 @@ private bool CreateCollection(IEnumerable links) { string midasBoundaryGroup = Adapters.MidasCivil.Convert.FromTag(link.Name); CompareGroup(midasBoundaryGroup, boundaryGroupPath); - midasRigidLinks.Add(Adapters.MidasCivil.Convert.FromRigidLink(link)); + midasRigidLinks.Add(Adapters.MidasCivil.Convert.FromRigidLink(link, m_midasCivilVersion)); } File.AppendAllLines(path, midasRigidLinks); diff --git a/MidasCivil_Adapter/CRUD/Read/Elements/RigidLinks.cs b/MidasCivil_Adapter/CRUD/Read/Elements/RigidLinks.cs index 3a9246cf..864008fe 100644 --- a/MidasCivil_Adapter/CRUD/Read/Elements/RigidLinks.cs +++ b/MidasCivil_Adapter/CRUD/Read/Elements/RigidLinks.cs @@ -47,7 +47,7 @@ private List ReadRigidLinks(List ids = null) foreach (string link in linkText) { - RigidLink bhomRigidLink = Adapters.MidasCivil.Convert.ToRigidLink(link, nodeDictionary, count); + RigidLink bhomRigidLink = Adapters.MidasCivil.Convert.ToRigidLink(link, nodeDictionary, count, m_midasCivilVersion); bhomRigidLinks.Add(bhomRigidLink); if (string.IsNullOrWhiteSpace(link.Split(',')[3].Trim())) diff --git a/MidasCivil_Adapter/Convert/ToBHoM/Elements/ToRigidLink.cs b/MidasCivil_Adapter/Convert/ToBHoM/Elements/ToRigidLink.cs index b04e4e8d..348d32e2 100644 --- a/MidasCivil_Adapter/Convert/ToBHoM/Elements/ToRigidLink.cs +++ b/MidasCivil_Adapter/Convert/ToBHoM/Elements/ToRigidLink.cs @@ -32,7 +32,7 @@ namespace BH.Adapter.Adapters.MidasCivil { public static partial class Convert { - public static RigidLink ToRigidLink(string rigidLink, Dictionary nodes, int count) + public static RigidLink ToRigidLink(string rigidLink, Dictionary nodes, int count, string version) { /***************************************************/ /**** Public Methods ****/ @@ -41,9 +41,44 @@ public static RigidLink ToRigidLink(string rigidLink, Dictionary n string[] delimitted = rigidLink.Split(','); List secondaryNodes = new List(); - string primaryId = delimitted[1].Trim(); - string fixity = delimitted[2].Replace(" ", ""); - List secondaryIds = delimitted[3].Split(' ').Where(m => !string.IsNullOrWhiteSpace(m)).ToList(); + string primaryId = ""; + string fixity = ""; + List secondaryIds = new List(); + + string name = ""; + + switch (version) + { + case "9.0.5": + case "9.1.0": + case "9.4.0": + primaryId = delimitted[0].Trim(); + fixity = delimitted[1].Replace(" ", ""); + secondaryIds = delimitted[2].Split(' ').Where(m => !string.IsNullOrWhiteSpace(m)).ToList(); + if (string.IsNullOrWhiteSpace(delimitted[3])) + { + name = "RL" + count; + } + else + { + name = delimitted[3].Trim(); + } + break; + default: + primaryId = delimitted[1].Trim(); + fixity = delimitted[2].Replace(" ", ""); + secondaryIds = delimitted[3].Split(' ').Where(m => !string.IsNullOrWhiteSpace(m)).ToList(); + if (string.IsNullOrWhiteSpace(delimitted[4])) + { + name = "RL" + count; + } + else + { + name = delimitted[4].Trim(); + } + break; + } + List assignments = MidasCivilAdapter.GetAssignmentIds(secondaryIds); bool x = FromFixity(fixity.Substring(0, 1)); @@ -65,17 +100,6 @@ public static RigidLink ToRigidLink(string rigidLink, Dictionary n secondaryNodes.Add(secondaryNode); } - string name = ""; - - if (string.IsNullOrWhiteSpace(delimitted[4])) - { - name = "RL" + count; - } - else - { - name = delimitted[4].Trim(); - } - RigidLink bhomRigidLink = new RigidLink { PrimaryNode = primaryNode, SecondaryNodes = secondaryNodes, Constraint = constraint }; bhomRigidLink.Name = name; bhomRigidLink.SetAdapterId(typeof(MidasCivilId), name); diff --git a/MidasCivil_Adapter/Convert/ToMidasCivil/Elements/FromRigidLink.cs b/MidasCivil_Adapter/Convert/ToMidasCivil/Elements/FromRigidLink.cs index d4e3db30..bf5eaeb1 100644 --- a/MidasCivil_Adapter/Convert/ToMidasCivil/Elements/FromRigidLink.cs +++ b/MidasCivil_Adapter/Convert/ToMidasCivil/Elements/FromRigidLink.cs @@ -32,7 +32,7 @@ public static partial class Convert /**** Public Methods ****/ /***************************************************/ - public static string FromRigidLink(this RigidLink link) + public static string FromRigidLink(this RigidLink link, string version) { string midasLink = ""; @@ -51,7 +51,17 @@ public static string FromRigidLink(this RigidLink link) BoolToFixity(link.Constraint.YYtoYY) + BoolToFixity(link.Constraint.ZZtoZZ); - midasLink = "1, " + primaryId + "," + fixity + "," + secondaryId + "," + link.Name; + switch (version) + { + case "9.0.5": + case "9.1.0": + case "9.4.0": + midasLink = primaryId + "," + fixity + "," + secondaryId + "," + link.Name; + break; + default: + midasLink = "1, " + primaryId + "," + fixity + "," + secondaryId + "," + link.Name; + break; + } return midasLink; } From 51eaa649b08c0376b47636753a03f91d275fcb72 Mon Sep 17 00:00:00 2001 From: Peter Nugent Date: Mon, 3 Jul 2023 09:25:08 +0100 Subject: [PATCH 4/9] Fixed bug where BarReleases were not being pulled correctly --- MidasCivil_Adapter/PrivateHelpers/AssignBarRelease.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MidasCivil_Adapter/PrivateHelpers/AssignBarRelease.cs b/MidasCivil_Adapter/PrivateHelpers/AssignBarRelease.cs index f9b4e2f1..2ed8c08a 100644 --- a/MidasCivil_Adapter/PrivateHelpers/AssignBarRelease.cs +++ b/MidasCivil_Adapter/PrivateHelpers/AssignBarRelease.cs @@ -63,7 +63,7 @@ private void AssignBarRelease(string bhomID, string propertyName, string section } else { - split[0] = bhomID; + split[0] = bhomID + " "; } string updatedProperty = split[0]; From da69891fbdb94ec3c318377ce6fda873bc8ca228 Mon Sep 17 00:00:00 2001 From: Peter Nugent Date: Thu, 6 Jul 2023 13:06:33 +0100 Subject: [PATCH 5/9] Changes to MaterialCombination due to Cache changes --- MidasCivil_Adapter/MidasCivilAdapter.cs | 2 +- .../GetSectionMaterialCombinations.cs | 95 ++++++++++--------- 2 files changed, 53 insertions(+), 44 deletions(-) diff --git a/MidasCivil_Adapter/MidasCivilAdapter.cs b/MidasCivil_Adapter/MidasCivilAdapter.cs index 53cd8268..23dd5959 100644 --- a/MidasCivil_Adapter/MidasCivilAdapter.cs +++ b/MidasCivil_Adapter/MidasCivilAdapter.cs @@ -50,7 +50,7 @@ public MidasCivilAdapter(string filePath, bool active = false, string version = if (active) { AdapterIdFragmentType = typeof(MidasCivilId); - this.m_AdapterSettings.CacheCRUDobjects = false; + this.m_AdapterSettings.CacheCRUDobjects = true; Modules.Structure.ModuleLoader.LoadModules(this); AdapterComparers = new Dictionary diff --git a/MidasCivil_Adapter/PrivateHelpers/GetSectionMaterialCombinations.cs b/MidasCivil_Adapter/PrivateHelpers/GetSectionMaterialCombinations.cs index 8e0a9761..6e87cc7f 100644 --- a/MidasCivil_Adapter/PrivateHelpers/GetSectionMaterialCombinations.cs +++ b/MidasCivil_Adapter/PrivateHelpers/GetSectionMaterialCombinations.cs @@ -51,52 +51,61 @@ private static Dictionary GetSectionMaterialCombinatio materials.TryGetValue(materialId.ToString(), out material); sectionProperties.TryGetValue(sectionPropertyId.ToString(), out section); - GenericSection genericSection = (GenericSection)section; + if (section is ISectionProperty) + { + //Needed to get the ShapeProfile + GenericSection genericSection = (GenericSection)section; - switch (material.GetType().ToString().Split('.').Last()) + switch (material.GetType().ToString().Split('.').Last()) + { + case "Concrete": + ConcreteSection concreteSection = Engine.Structure.Create.ConcreteSectionFromProfile(genericSection.SectionProfile, (Concrete)material); + concreteSection.Name = genericSection.Name; + concreteSection.SetAdapterId(typeof(MidasCivilId), sectionPropertyId); + materialSections.Add(materialId.ToString() + "," + sectionPropertyId.ToString(), concreteSection); + break; + case "Steel": + SteelSection steelSection = Engine.Structure.Create.SteelSectionFromProfile(genericSection.SectionProfile, (Steel)material); + steelSection.Name = genericSection.Name; + steelSection.SetAdapterId(typeof(MidasCivilId), sectionPropertyId); + materialSections.Add(materialId.ToString() + "," + sectionPropertyId.ToString(), steelSection); + break; + case "Aluminium": + AluminiumSection aluminiumSection = Engine.Structure.Create.AluminiumSectionFromProfile(genericSection.SectionProfile, (Aluminium)material); + aluminiumSection.Name = genericSection.Name; + aluminiumSection.SetAdapterId(typeof(MidasCivilId), sectionPropertyId); + materialSections.Add(materialId.ToString() + "," + sectionPropertyId.ToString(), aluminiumSection); + break; + case "Timber": + TimberSection timberSection = Engine.Structure.Create.TimberSectionFromProfile(genericSection.SectionProfile, (Timber)material); + timberSection.Name = genericSection.Name; + timberSection.SetAdapterId(typeof(MidasCivilId), sectionPropertyId); + materialSections.Add(materialId.ToString() + "," + sectionPropertyId.ToString(), timberSection); + break; + case "GenericIsotropicMaterial": + GenericSection genericIsoptropicSection = + Engine.Structure.Create.GenericSectionFromProfile(genericSection.SectionProfile, (GenericIsotropicMaterial)material); + genericIsoptropicSection.Name = genericSection.Name; + genericIsoptropicSection.SetAdapterId(typeof(MidasCivilId), sectionPropertyId); + materialSections.Add(materialId.ToString() + "," + sectionPropertyId.ToString(), genericIsoptropicSection); + break; + case "GenericOrthotropicMaterial": + GenericSection genericOrthotropicSection = + Engine.Structure.Create.GenericSectionFromProfile(genericSection.SectionProfile, (GenericOrthotropicMaterial)material); + genericOrthotropicSection.Name = genericSection.Name; + genericOrthotropicSection.SetAdapterId(typeof(MidasCivilId), sectionPropertyId); + materialSections.Add(materialId.ToString() + "," + sectionPropertyId.ToString(), genericOrthotropicSection); + break; + default: + Engine.Base.Compute.RecordError(material.GetType().ToString().Split('.').Last() + "not recognised"); + break; + } + } + else { - case "Concrete": - ConcreteSection concreteSection = Engine.Structure.Create.ConcreteSectionFromProfile(genericSection.SectionProfile, (Concrete)material); - concreteSection.Name = genericSection.Name; - concreteSection.SetAdapterId(typeof(MidasCivilId),sectionPropertyId); - materialSections.Add(materialId.ToString() + "," + sectionPropertyId.ToString(), concreteSection); - break; - case "Steel": - SteelSection steelSection = Engine.Structure.Create.SteelSectionFromProfile(genericSection.SectionProfile, (Steel)material); - steelSection.Name = genericSection.Name; - steelSection.SetAdapterId(typeof(MidasCivilId), sectionPropertyId); - materialSections.Add(materialId.ToString() + "," + sectionPropertyId.ToString(), steelSection); - break; - case "Aluminium": - AluminiumSection aluminiumSection = Engine.Structure.Create.AluminiumSectionFromProfile(genericSection.SectionProfile, (Aluminium)material); - aluminiumSection.Name = genericSection.Name; - aluminiumSection.SetAdapterId(typeof(MidasCivilId), sectionPropertyId); - materialSections.Add(materialId.ToString() + "," + sectionPropertyId.ToString(), aluminiumSection); - break; - case "Timber": - TimberSection timberSection = Engine.Structure.Create.TimberSectionFromProfile(genericSection.SectionProfile, (Timber)material); - timberSection.Name = genericSection.Name; - timberSection.SetAdapterId(typeof(MidasCivilId), sectionPropertyId); - materialSections.Add(materialId.ToString() + "," + sectionPropertyId.ToString(), timberSection); - break; - case "GenericIsotropicMaterial": - GenericSection genericIsoptropicSection = - Engine.Structure.Create.GenericSectionFromProfile(genericSection.SectionProfile, (GenericIsotropicMaterial)material); - genericIsoptropicSection.Name = genericSection.Name; - genericIsoptropicSection.SetAdapterId(typeof(MidasCivilId), sectionPropertyId); - materialSections.Add(materialId.ToString() + "," + sectionPropertyId.ToString(), genericIsoptropicSection); - break; - case "GenericOrthotropicMaterial": - GenericSection genericOrthotropicSection = - Engine.Structure.Create.GenericSectionFromProfile(genericSection.SectionProfile, (GenericOrthotropicMaterial)material); - genericOrthotropicSection.Name = genericSection.Name; - genericOrthotropicSection.SetAdapterId(typeof(MidasCivilId), sectionPropertyId); - materialSections.Add(materialId.ToString() + "," + sectionPropertyId.ToString(), genericOrthotropicSection); - break; - default: - Engine.Base.Compute.RecordError(material.GetType().ToString().Split('.').Last() + "not recognised"); - break; + materialSections.Add(materialId.ToString() + "," + sectionPropertyId.ToString(),section); } + } return materialSections; From b4a1cdd5e5c62ec735c4d17d27d94745979d8bf4 Mon Sep 17 00:00:00 2001 From: Peter Nugent Date: Mon, 17 Jul 2023 12:02:00 +0100 Subject: [PATCH 6/9] Rearrange if statement for cached sections --- .../PrivateHelpers/GetSectionMaterialCombinations.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MidasCivil_Adapter/PrivateHelpers/GetSectionMaterialCombinations.cs b/MidasCivil_Adapter/PrivateHelpers/GetSectionMaterialCombinations.cs index 6e87cc7f..0ba2945f 100644 --- a/MidasCivil_Adapter/PrivateHelpers/GetSectionMaterialCombinations.cs +++ b/MidasCivil_Adapter/PrivateHelpers/GetSectionMaterialCombinations.cs @@ -51,7 +51,11 @@ private static Dictionary GetSectionMaterialCombinatio materials.TryGetValue(materialId.ToString(), out material); sectionProperties.TryGetValue(sectionPropertyId.ToString(), out section); - if (section is ISectionProperty) + if(section is SteelSection || section is ConcreteSection || section is AluminiumSection || section is TimberSection) + { + materialSections.Add(materialId.ToString() + "," + sectionPropertyId.ToString(), section); + } + else { //Needed to get the ShapeProfile GenericSection genericSection = (GenericSection)section; @@ -101,10 +105,6 @@ private static Dictionary GetSectionMaterialCombinatio break; } } - else - { - materialSections.Add(materialId.ToString() + "," + sectionPropertyId.ToString(),section); - } } From 10fba6b124ce5212eba847cb772e43a2bd8510b5 Mon Sep 17 00:00:00 2001 From: Peter Nugent Date: Tue, 1 Aug 2023 15:05:51 +0100 Subject: [PATCH 7/9] Rearrange FromFixity method to satifiy BarRelease,Constraint4DOF, Constraint6DOF and RigidLink --- .../Convert/ToBHoM/Properties/ToBarRelease.cs | 4 ++-- .../ToMidasCivil/Properties/FromFixity.cs | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/MidasCivil_Adapter/Convert/ToBHoM/Properties/ToBarRelease.cs b/MidasCivil_Adapter/Convert/ToBHoM/Properties/ToBarRelease.cs index d410548a..1d3342cc 100644 --- a/MidasCivil_Adapter/Convert/ToBHoM/Properties/ToBarRelease.cs +++ b/MidasCivil_Adapter/Convert/ToBHoM/Properties/ToBarRelease.cs @@ -48,8 +48,8 @@ public static BarRelease ToBarRelease(string release, int count) for (int i = 0; i < 6; i++) { - bhomStartFixity.Add(FromFixity(startFixity.Substring(i, 1))); - bhomEndFixity.Add(FromFixity(endFixity.Substring(i, 1))); + bhomStartFixity.Add(FromFixity(startFixity.Substring(i, 1),true)); + bhomEndFixity.Add(FromFixity(endFixity.Substring(i, 1), true)); } Constraint6DOF startConstraint = Engine.Structure.Create.Constraint6DOF(bhomStartFixity[0], bhomStartFixity[1], bhomStartFixity[2], diff --git a/MidasCivil_Adapter/Convert/ToMidasCivil/Properties/FromFixity.cs b/MidasCivil_Adapter/Convert/ToMidasCivil/Properties/FromFixity.cs index 468b2145..380a9971 100644 --- a/MidasCivil_Adapter/Convert/ToMidasCivil/Properties/FromFixity.cs +++ b/MidasCivil_Adapter/Convert/ToMidasCivil/Properties/FromFixity.cs @@ -28,15 +28,26 @@ public static partial class Convert /**** Public Methods ****/ /***************************************************/ - internal static bool FromFixity(string number) + internal static bool FromFixity(string number, bool release = false) { bool fixity = true; - if (int.Parse(number) == 1) + if(release) { - fixity = false; + // For bar releases + if (int.Parse(number.Trim()) == 1) + { + fixity = false; + } + } + else + { + // For constraints, rigid links etc. + if (int.Parse(number.Trim()) == 0) + { + fixity = false; + } } - return fixity; } From 00bd6aac82a693595f3cf7b81ac87e5f7d1eafe2 Mon Sep 17 00:00:00 2001 From: peterjamesnugent Date: Thu, 17 Aug 2023 10:49:15 +0100 Subject: [PATCH 8/9] Update unit conversion for temperature profile --- .../ToMidasCivil/Loads/FromAreaDifferentialTemperatureLoad.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MidasCivil_Adapter/Convert/ToMidasCivil/Loads/FromAreaDifferentialTemperatureLoad.cs b/MidasCivil_Adapter/Convert/ToMidasCivil/Loads/FromAreaDifferentialTemperatureLoad.cs index fcdd2097..686f3053 100644 --- a/MidasCivil_Adapter/Convert/ToMidasCivil/Loads/FromAreaDifferentialTemperatureLoad.cs +++ b/MidasCivil_Adapter/Convert/ToMidasCivil/Loads/FromAreaDifferentialTemperatureLoad.cs @@ -33,7 +33,7 @@ public static partial class Convert public static string FromAreaDifferentialTemperatureLoad(this AreaDifferentialTemperatureLoad temperatureProfile, string assignedFEMesh, string temperatureUnit) { string midasFEMeshLoad = null; - double temperatureDifference = temperatureProfile.TemperatureProfile[0].DeltaTemperatureToSI(temperatureUnit) - temperatureProfile.TemperatureProfile[1].DeltaTemperatureToSI(temperatureUnit); + double temperatureDifference = temperatureProfile.TemperatureProfile[0].DeltaTemperatureFromSI(temperatureUnit) - temperatureProfile.TemperatureProfile[1].DeltaTemperatureFromSI(temperatureUnit); midasFEMeshLoad = assignedFEMesh + ",2," + temperatureDifference + "," + "YES,0," + temperatureProfile.Name; return midasFEMeshLoad; } From 91be6c2494519caacda30007474e3d1fb616152b Mon Sep 17 00:00:00 2001 From: peterjamesnugent Date: Thu, 17 Aug 2023 17:16:07 +0100 Subject: [PATCH 9/9] Fixed a bug where for MCTs exported from Midas that had no spaces (not the case when pushed from the BHoM) --- MidasCivil_Adapter/PrivateHelpers/GetBarReleaseAssignments.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MidasCivil_Adapter/PrivateHelpers/GetBarReleaseAssignments.cs b/MidasCivil_Adapter/PrivateHelpers/GetBarReleaseAssignments.cs index 52e2bf38..05b9faf0 100644 --- a/MidasCivil_Adapter/PrivateHelpers/GetBarReleaseAssignments.cs +++ b/MidasCivil_Adapter/PrivateHelpers/GetBarReleaseAssignments.cs @@ -50,6 +50,10 @@ private Dictionary> GetBarReleaseAssignments(string section, s Where(x => !string.IsNullOrEmpty(x)). ToList(); } + else + { + geometryAssignments.Add(splitSection.Trim()); + } List propertyAssignment = MidasCivilAdapter.GetAssignmentIds(geometryAssignments);