From b5412d70d634d0509281c04a7c95723679925029 Mon Sep 17 00:00:00 2001 From: BHoMBot Date: Mon, 25 Sep 2023 14:31:55 +0100 Subject: [PATCH 1/9] Upgrade AssemblyFileVersion to 7.0.0.0 --- GSA_Adapter/Properties/AssemblyInfo.cs | 4 ++-- GSA_Engine/Properties/AssemblyInfo.cs | 4 ++-- GSA_oM/Properties/AssemblyInfo.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/GSA_Adapter/Properties/AssemblyInfo.cs b/GSA_Adapter/Properties/AssemblyInfo.cs index 03f2d73e..9a0d316a 100644 --- a/GSA_Adapter/Properties/AssemblyInfo.cs +++ b/GSA_Adapter/Properties/AssemblyInfo.cs @@ -53,8 +53,8 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("6.0.0.0")] -[assembly: AssemblyFileVersion("6.3.0.0")] +[assembly: AssemblyVersion("7.0.0.0")] +[assembly: AssemblyFileVersion("7.0.0.0")] diff --git a/GSA_Engine/Properties/AssemblyInfo.cs b/GSA_Engine/Properties/AssemblyInfo.cs index 417fe7f4..f04ac9a6 100644 --- a/GSA_Engine/Properties/AssemblyInfo.cs +++ b/GSA_Engine/Properties/AssemblyInfo.cs @@ -53,8 +53,8 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("6.0.0.0")] -[assembly: AssemblyFileVersion("6.3.0.0")] +[assembly: AssemblyVersion("7.0.0.0")] +[assembly: AssemblyFileVersion("7.0.0.0")] diff --git a/GSA_oM/Properties/AssemblyInfo.cs b/GSA_oM/Properties/AssemblyInfo.cs index 79948642..376091f5 100644 --- a/GSA_oM/Properties/AssemblyInfo.cs +++ b/GSA_oM/Properties/AssemblyInfo.cs @@ -54,8 +54,8 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("6.0.0.0")] -[assembly: AssemblyFileVersion("6.3.0.0")] +[assembly: AssemblyVersion("7.0.0.0")] +[assembly: AssemblyFileVersion("7.0.0.0")] From b526e283a2e29a0a2578c660b6f1c68afbc46bb4 Mon Sep 17 00:00:00 2001 From: Johanna Isaksson Date: Thu, 23 Mar 2023 14:29:25 +0000 Subject: [PATCH 2/9] Revert "Revert "Shear modulus and thermal coefficient value fix"" This reverts commit 85da75193d85246251226e668cde3054fe67d2f6. --- GSA_Adapter/CRUD/ReadResultsElements.cs | 138 ++++++++++++++++++ .../FromGsa/Properties/SectionProperty.cs | 11 ++ .../Convert/FromGsa/Results/Results.cs | 26 ++++ GSA_Adapter/GSA_Adapter.csproj | 8 +- 4 files changed, 179 insertions(+), 4 deletions(-) diff --git a/GSA_Adapter/CRUD/ReadResultsElements.cs b/GSA_Adapter/CRUD/ReadResultsElements.cs index cfa64938..38eaa71d 100644 --- a/GSA_Adapter/CRUD/ReadResultsElements.cs +++ b/GSA_Adapter/CRUD/ReadResultsElements.cs @@ -38,6 +38,7 @@ using System.Collections.Generic; using System.Linq; using BH.Engine.Adapters.GSA; +using BH.oM.Structure.Results; namespace BH.Adapter.GSA { @@ -218,6 +219,99 @@ private bool GetExtractionParameters(NodeResultRequest request, out ResHeader he /***************************************************/ + private bool GetExtractionParameters(MeshResultRequest request, out ResHeader header, out ForceConverter converter, out string axis, out double unitFactor, out int divisions, out int flags) + { + axis = Output_Axis.Local; + divisions = 0; + flags = 0; + + double[] unitFactors = GetUnitFactors(); + + switch (request.LayerPosition) + { + case -1: + flags = (int)Output_Init_Flags.OP_INIT_2D_BOTTOM; + break; + case 0: + flags = (int)Output_Init_Flags.OP_INIT_2D_MIDDLE; + break; + case 1: + flags = (int)Output_Init_Flags.OP_INIT_2D_TOP; + break; + case 2: + converter = null; + header = ResHeader.REF_ACC; + unitFactor = unitFactors[(int)UnitType.FORCE]; + flags = 0; + Engine.Base.Compute.RecordError("Result of layer position " + request.LayerPosition + " is not yet supported"); + return false; + case 3: + converter = null; + header = ResHeader.REF_ACC; + unitFactor = unitFactors[(int)UnitType.FORCE]; + flags = 0; + Engine.Base.Compute.RecordError("Result of layer position " + request.LayerPosition + " is not yet supported"); + return false; + case 4: + converter = null; + header = ResHeader.REF_ACC; + unitFactor = unitFactors[(int)UnitType.FORCE]; + flags = 0; + Engine.Base.Compute.RecordError("Result of layer position " + request.LayerPosition + " is not yet supported"); + return false; + case 5: + converter = null; + header = ResHeader.REF_ACC; + unitFactor = unitFactors[(int)UnitType.FORCE]; + flags = 0; + Engine.Base.Compute.RecordError("Result of layer position " + request.LayerPosition + " is not yet supported"); + return false; + } + + switch (request.ResultType) + { + case MeshResultType.Forces: + converter = null; + header = ResHeader.REF_FORCE_EL2D_DRV; + unitFactor = unitFactors[(int)UnitType.FORCE]; + Engine.Base.Compute.RecordError("Result of layer position " + request.ResultType + " is not yet supported"); + return false; + case MeshResultType.Displacements: + converter = null; + header = ResHeader.REF_DISP_EL2D; + unitFactor = unitFactors[(int)UnitType.LENGTH]; + Engine.Base.Compute.RecordError("Result of layer position " + request.ResultType + " is not yet supported"); + return false; + case MeshResultType.MeshModeShape: + converter = null; + header = ResHeader.REF_ACC; + unitFactor = 1; + Engine.Base.Compute.RecordError("Result of layer position " + request.ResultType + " is not yet supported"); + return false; + case MeshResultType.Stresses: + converter = Convert.FromGsaMeshStress; + header = ResHeader.REF_STRESS_EL2D_DRV; + unitFactor = unitFactors[(int)UnitType.STRESS]; + break; + case MeshResultType.VonMises: + converter = null; + header = ResHeader.REF_ACC; + unitFactor = 1; + Engine.Base.Compute.RecordError("Result of layer position " + request.ResultType + " is not yet supported"); + return false; + default: + converter = null; + header = ResHeader.REF_ACC; + unitFactor = 1; + Engine.Base.Compute.RecordError("Result of type " + request.ResultType + " is not yet supported"); + return false; + } + + return true; + } + + /***************************************************/ + private bool IGetExtractionParameters(IResultRequest request, out ResHeader header, out ForceConverter converter, out string axis, out double unitFactor, out int divisions, out int flags) { return GetExtractionParameters(request as dynamic, out header, out converter, out axis, out unitFactor, out divisions, out flags); @@ -375,6 +469,50 @@ private List GetAllIds(NodeResultRequest request) } + /***************************************************/ + + private List GetAllIds(MeshResultRequest request) + { + string allBars = m_gsaCom.GwaCommand("GET_ALL, EL.2").ToString(); + string[] barArr = string.IsNullOrWhiteSpace(allBars) ? new string[0] : allBars.Split('\n'); + + List ids = new List(); + bool containsDummies = false; + foreach (string gsaBar in barArr) + { + + string[] arr = gsaBar.Split(','); + + string index = arr[1]; + + //Check that the element type is a mesh + switch (arr[4]) + { + case "TRI3": + case "TRI6": + case "QUAD4": + case "QUAD8": + break; + default: + continue; + } + + //Check if dummy + if (arr.Last().ToUpper() == "DUMMY") + { + containsDummies = true; + continue; + } + + ids.Add(int.Parse(index)); + } + + if (containsDummies) + Engine.Base.Compute.RecordNote("Model contains 'dummy'-elements. The elements with this tag do not contain any results and will not have any results extracted."); + + return ids; + } + /***************************************************/ static public int[] CreateIntSequence(int maxId) diff --git a/GSA_Adapter/Convert/FromGsa/Properties/SectionProperty.cs b/GSA_Adapter/Convert/FromGsa/Properties/SectionProperty.cs index 24606c50..c35f5a9f 100644 --- a/GSA_Adapter/Convert/FromGsa/Properties/SectionProperty.cs +++ b/GSA_Adapter/Convert/FromGsa/Properties/SectionProperty.cs @@ -124,6 +124,7 @@ public static ISectionProperty FromGsaSectionProperty(string gsaString, Dictiona else { secName = secName.TrimEnd((".0").ToCharArray()); + if (desc[1].Contains("CHS")) { description = "STD" + splitChar + secType + splitChar; @@ -144,6 +145,16 @@ public static ISectionProperty FromGsaSectionProperty(string gsaString, Dictiona Engine.Base.Compute.RecordNote("Section of type: " + secName + " not found in the library. Custom section will be used"); } + else if (desc[1].Contains("CHS")) + { + description = "STD%" + secType + "%"; + string trim = desc[2].TrimStart(secType.ToCharArray()); + string[] arr = trim.Split('x'); + + description += arr[0] + "%" + arr[1]; + + Engine.Base.Compute.RecordNote("Section of type: " + secName + " not found in the library. Custom section will be used"); + } else { message += "Catalogue section of type " + secName + " not found in library\n"; diff --git a/GSA_Adapter/Convert/FromGsa/Results/Results.cs b/GSA_Adapter/Convert/FromGsa/Results/Results.cs index b3e0890b..43f6e5f6 100644 --- a/GSA_Adapter/Convert/FromGsa/Results/Results.cs +++ b/GSA_Adapter/Convert/FromGsa/Results/Results.cs @@ -189,6 +189,32 @@ public static BarStrain FromGsaBarStrain(GsaResults results, int id, string load /***************************************************/ + public static MeshStress FromGsaMeshStress(GsaResults results, int id, string loadCase, int divisions, double timeStep = 0, int mode = -1) + { + return new MeshStress( + id, + 0, + 0, + loadCase, + mode, + timeStep, + MeshResultLayer.Lower, + -1, + MeshResultSmoothingType.None, + oM.Geometry.Basis.XY, + results.dynaResults[0], + results.dynaResults[1], + results.dynaResults[2], + results.dynaResults[4], + results.dynaResults[3], + results.dynaResults[6], + results.dynaResults[5], + results.dynaResults[7] + ); + } + + /***************************************************/ + public static GlobalReactions FromGsaGlobalReactions(string id, string force, string moment) { string[] fArr = force.Split(','); diff --git a/GSA_Adapter/GSA_Adapter.csproj b/GSA_Adapter/GSA_Adapter.csproj index 19ba8d0b..4d568288 100644 --- a/GSA_Adapter/GSA_Adapter.csproj +++ b/GSA_Adapter/GSA_Adapter.csproj @@ -1,4 +1,4 @@ - + @@ -20,7 +20,7 @@ DEBUG;TRACE;GSA_8_7 prompt 4 - GSA87_Adapter + GSA87_Adapter pdbonly @@ -29,7 +29,7 @@ TRACE;GSA_8_7 prompt 4 - GSA87_Adapter + GSA87_Adapter true @@ -258,4 +258,4 @@ xcopy "$(TargetDir)$(TargetFileName)" "$(ProgramData)\BHoM\Assemblies" /Y - + \ No newline at end of file From 082e13281c874ac008e7e3f41afe62a2ee70df96 Mon Sep 17 00:00:00 2001 From: Johanna Isaksson Date: Thu, 23 Mar 2023 14:30:50 +0000 Subject: [PATCH 3/9] Revert "Revert "Revert "Shear modulus and thermal coefficient value fix""" This reverts commit bed84d1333c0665d2f0732c8f832434afc483d12. --- GSA_Adapter/CRUD/ReadResultsElements.cs | 138 ------------------ .../Convert/FromGsa/Properties/Material.cs | 12 +- .../FromGsa/Properties/SectionProperty.cs | 10 -- .../Convert/FromGsa/Results/Results.cs | 26 ---- GSA_Adapter/GSA_Adapter.csproj | 8 +- 5 files changed, 10 insertions(+), 184 deletions(-) diff --git a/GSA_Adapter/CRUD/ReadResultsElements.cs b/GSA_Adapter/CRUD/ReadResultsElements.cs index 38eaa71d..cfa64938 100644 --- a/GSA_Adapter/CRUD/ReadResultsElements.cs +++ b/GSA_Adapter/CRUD/ReadResultsElements.cs @@ -38,7 +38,6 @@ using System.Collections.Generic; using System.Linq; using BH.Engine.Adapters.GSA; -using BH.oM.Structure.Results; namespace BH.Adapter.GSA { @@ -219,99 +218,6 @@ private bool GetExtractionParameters(NodeResultRequest request, out ResHeader he /***************************************************/ - private bool GetExtractionParameters(MeshResultRequest request, out ResHeader header, out ForceConverter converter, out string axis, out double unitFactor, out int divisions, out int flags) - { - axis = Output_Axis.Local; - divisions = 0; - flags = 0; - - double[] unitFactors = GetUnitFactors(); - - switch (request.LayerPosition) - { - case -1: - flags = (int)Output_Init_Flags.OP_INIT_2D_BOTTOM; - break; - case 0: - flags = (int)Output_Init_Flags.OP_INIT_2D_MIDDLE; - break; - case 1: - flags = (int)Output_Init_Flags.OP_INIT_2D_TOP; - break; - case 2: - converter = null; - header = ResHeader.REF_ACC; - unitFactor = unitFactors[(int)UnitType.FORCE]; - flags = 0; - Engine.Base.Compute.RecordError("Result of layer position " + request.LayerPosition + " is not yet supported"); - return false; - case 3: - converter = null; - header = ResHeader.REF_ACC; - unitFactor = unitFactors[(int)UnitType.FORCE]; - flags = 0; - Engine.Base.Compute.RecordError("Result of layer position " + request.LayerPosition + " is not yet supported"); - return false; - case 4: - converter = null; - header = ResHeader.REF_ACC; - unitFactor = unitFactors[(int)UnitType.FORCE]; - flags = 0; - Engine.Base.Compute.RecordError("Result of layer position " + request.LayerPosition + " is not yet supported"); - return false; - case 5: - converter = null; - header = ResHeader.REF_ACC; - unitFactor = unitFactors[(int)UnitType.FORCE]; - flags = 0; - Engine.Base.Compute.RecordError("Result of layer position " + request.LayerPosition + " is not yet supported"); - return false; - } - - switch (request.ResultType) - { - case MeshResultType.Forces: - converter = null; - header = ResHeader.REF_FORCE_EL2D_DRV; - unitFactor = unitFactors[(int)UnitType.FORCE]; - Engine.Base.Compute.RecordError("Result of layer position " + request.ResultType + " is not yet supported"); - return false; - case MeshResultType.Displacements: - converter = null; - header = ResHeader.REF_DISP_EL2D; - unitFactor = unitFactors[(int)UnitType.LENGTH]; - Engine.Base.Compute.RecordError("Result of layer position " + request.ResultType + " is not yet supported"); - return false; - case MeshResultType.MeshModeShape: - converter = null; - header = ResHeader.REF_ACC; - unitFactor = 1; - Engine.Base.Compute.RecordError("Result of layer position " + request.ResultType + " is not yet supported"); - return false; - case MeshResultType.Stresses: - converter = Convert.FromGsaMeshStress; - header = ResHeader.REF_STRESS_EL2D_DRV; - unitFactor = unitFactors[(int)UnitType.STRESS]; - break; - case MeshResultType.VonMises: - converter = null; - header = ResHeader.REF_ACC; - unitFactor = 1; - Engine.Base.Compute.RecordError("Result of layer position " + request.ResultType + " is not yet supported"); - return false; - default: - converter = null; - header = ResHeader.REF_ACC; - unitFactor = 1; - Engine.Base.Compute.RecordError("Result of type " + request.ResultType + " is not yet supported"); - return false; - } - - return true; - } - - /***************************************************/ - private bool IGetExtractionParameters(IResultRequest request, out ResHeader header, out ForceConverter converter, out string axis, out double unitFactor, out int divisions, out int flags) { return GetExtractionParameters(request as dynamic, out header, out converter, out axis, out unitFactor, out divisions, out flags); @@ -469,50 +375,6 @@ private List GetAllIds(NodeResultRequest request) } - /***************************************************/ - - private List GetAllIds(MeshResultRequest request) - { - string allBars = m_gsaCom.GwaCommand("GET_ALL, EL.2").ToString(); - string[] barArr = string.IsNullOrWhiteSpace(allBars) ? new string[0] : allBars.Split('\n'); - - List ids = new List(); - bool containsDummies = false; - foreach (string gsaBar in barArr) - { - - string[] arr = gsaBar.Split(','); - - string index = arr[1]; - - //Check that the element type is a mesh - switch (arr[4]) - { - case "TRI3": - case "TRI6": - case "QUAD4": - case "QUAD8": - break; - default: - continue; - } - - //Check if dummy - if (arr.Last().ToUpper() == "DUMMY") - { - containsDummies = true; - continue; - } - - ids.Add(int.Parse(index)); - } - - if (containsDummies) - Engine.Base.Compute.RecordNote("Model contains 'dummy'-elements. The elements with this tag do not contain any results and will not have any results extracted."); - - return ids; - } - /***************************************************/ static public int[] CreateIntSequence(int maxId) diff --git a/GSA_Adapter/Convert/FromGsa/Properties/Material.cs b/GSA_Adapter/Convert/FromGsa/Properties/Material.cs index 6a8a180b..a60a892e 100644 --- a/GSA_Adapter/Convert/FromGsa/Properties/Material.cs +++ b/GSA_Adapter/Convert/FromGsa/Properties/Material.cs @@ -203,13 +203,13 @@ private static void OrthotropicMaterialProperties(string gsaString, out double e v2 = double.Parse(gStr[10]); v3 = double.Parse(gStr[11]); - g1 = double.Parse(gStr[16]); - g2 = double.Parse(gStr[17]); - g3 = double.Parse(gStr[18]); + g1 = double.Parse(gStr[13]); + g2 = double.Parse(gStr[14]); + g3 = double.Parse(gStr[15]); - tC1 = double.Parse(gStr[13]); - tC2 = double.Parse(gStr[14]); - tC3 = double.Parse(gStr[15]); + tC1 = double.Parse(gStr[16]); + tC2 = double.Parse(gStr[17]); + tC3 = double.Parse(gStr[18]); rho = double.Parse(gStr[12]); diff --git a/GSA_Adapter/Convert/FromGsa/Properties/SectionProperty.cs b/GSA_Adapter/Convert/FromGsa/Properties/SectionProperty.cs index c35f5a9f..35f02b76 100644 --- a/GSA_Adapter/Convert/FromGsa/Properties/SectionProperty.cs +++ b/GSA_Adapter/Convert/FromGsa/Properties/SectionProperty.cs @@ -145,16 +145,6 @@ public static ISectionProperty FromGsaSectionProperty(string gsaString, Dictiona Engine.Base.Compute.RecordNote("Section of type: " + secName + " not found in the library. Custom section will be used"); } - else if (desc[1].Contains("CHS")) - { - description = "STD%" + secType + "%"; - string trim = desc[2].TrimStart(secType.ToCharArray()); - string[] arr = trim.Split('x'); - - description += arr[0] + "%" + arr[1]; - - Engine.Base.Compute.RecordNote("Section of type: " + secName + " not found in the library. Custom section will be used"); - } else { message += "Catalogue section of type " + secName + " not found in library\n"; diff --git a/GSA_Adapter/Convert/FromGsa/Results/Results.cs b/GSA_Adapter/Convert/FromGsa/Results/Results.cs index 43f6e5f6..b3e0890b 100644 --- a/GSA_Adapter/Convert/FromGsa/Results/Results.cs +++ b/GSA_Adapter/Convert/FromGsa/Results/Results.cs @@ -189,32 +189,6 @@ public static BarStrain FromGsaBarStrain(GsaResults results, int id, string load /***************************************************/ - public static MeshStress FromGsaMeshStress(GsaResults results, int id, string loadCase, int divisions, double timeStep = 0, int mode = -1) - { - return new MeshStress( - id, - 0, - 0, - loadCase, - mode, - timeStep, - MeshResultLayer.Lower, - -1, - MeshResultSmoothingType.None, - oM.Geometry.Basis.XY, - results.dynaResults[0], - results.dynaResults[1], - results.dynaResults[2], - results.dynaResults[4], - results.dynaResults[3], - results.dynaResults[6], - results.dynaResults[5], - results.dynaResults[7] - ); - } - - /***************************************************/ - public static GlobalReactions FromGsaGlobalReactions(string id, string force, string moment) { string[] fArr = force.Split(','); diff --git a/GSA_Adapter/GSA_Adapter.csproj b/GSA_Adapter/GSA_Adapter.csproj index 4d568288..19ba8d0b 100644 --- a/GSA_Adapter/GSA_Adapter.csproj +++ b/GSA_Adapter/GSA_Adapter.csproj @@ -1,4 +1,4 @@ - + @@ -20,7 +20,7 @@ DEBUG;TRACE;GSA_8_7 prompt 4 - GSA87_Adapter + GSA87_Adapter pdbonly @@ -29,7 +29,7 @@ TRACE;GSA_8_7 prompt 4 - GSA87_Adapter + GSA87_Adapter true @@ -258,4 +258,4 @@ xcopy "$(TargetDir)$(TargetFileName)" "$(ProgramData)\BHoM\Assemblies" /Y - \ No newline at end of file + From 697c5410aa9de88740709058f9e09b9894c8188d Mon Sep 17 00:00:00 2001 From: Toste Skanberg Dahlstedt Date: Tue, 2 May 2023 13:16:05 +0100 Subject: [PATCH 4/9] Added all functionality for reading, pushing and pulling rigid constraints --- GSA_Adapter/CRUD/Create.cs | 8 ++ GSA_Adapter/CRUD/Read.cs | 14 +++ .../FromGsa/Elements/RigidConstraint.cs | 101 ++++++++++++++++++ .../Convert/ToGsa/Elements/RigidConstraint.cs | 71 ++++++++++++ GSA_Adapter/GSAAdapter.cs | 1 + GSA_Adapter/GSA_Adapter.csproj | 2 + GSA_oM/Elements/RigidConstraint.cs | 54 ++++++++++ GSA_oM/Enum/RigidConstraintLinkType.cs | 47 ++++++++ GSA_oM/GSA_oM.csproj | 2 + 9 files changed, 300 insertions(+) create mode 100644 GSA_Adapter/Convert/FromGsa/Elements/RigidConstraint.cs create mode 100644 GSA_Adapter/Convert/ToGsa/Elements/RigidConstraint.cs create mode 100644 GSA_oM/Elements/RigidConstraint.cs create mode 100644 GSA_oM/Enum/RigidConstraintLinkType.cs diff --git a/GSA_Adapter/CRUD/Create.cs b/GSA_Adapter/CRUD/Create.cs index 94dfb9d3..5ed01f96 100644 --- a/GSA_Adapter/CRUD/Create.cs +++ b/GSA_Adapter/CRUD/Create.cs @@ -35,6 +35,7 @@ using BH.oM.Adapters.GSA.SurfaceProperties; using BH.oM.Structure.MaterialFragments; using BH.oM.Structure.Fragments; +using BH.oM.Adapters.GSA.Elements; namespace BH.Adapter.GSA { @@ -277,6 +278,13 @@ private bool CreateObject(FabricPanelProperty fabricProperty) } + /***************************************************/ + + private bool CreateObject(RigidConstraint rigidConstraint) + { + return ComCall(rigidConstraint.ToGsaString()); + } + /***************************************************/ } } diff --git a/GSA_Adapter/CRUD/Read.cs b/GSA_Adapter/CRUD/Read.cs index 7e817a77..12eb0ab0 100644 --- a/GSA_Adapter/CRUD/Read.cs +++ b/GSA_Adapter/CRUD/Read.cs @@ -83,6 +83,8 @@ protected override IEnumerable IRead(Type type, IList indices, Acti return ReadRigidLink(indices as dynamic); if (type == typeof(LinkConstraint)) return ReadLinkConstraint(indices as dynamic); + if (type == typeof(RigidConstraint)) + return ReadRigidConstraint(indices as dynamic); if (type == typeof(FEMesh)) return ReadFEMesh(indices as dynamic); if (type == typeof(ISurfaceProperty)) @@ -418,6 +420,18 @@ public List ReadRigidLink(List ids = null) /***************************************/ + public List ReadRigidConstraint(List ids = null) + { + string allProps = m_gsaCom.GwaCommand("GET_ALL, RIGID").ToString(); + string[] proArr = string.IsNullOrWhiteSpace(allProps) ? new string[0] : allProps.Split('\n'); + + Dictionary nodes = GetCachedOrReadAsDictionary(); + + return Convert.FromGsaRigidConstraint(proArr, nodes); + } + + /***************************************/ + public List ReadSpacers(List ids = null) { Dictionary nodes = GetCachedOrReadAsDictionary(); diff --git a/GSA_Adapter/Convert/FromGsa/Elements/RigidConstraint.cs b/GSA_Adapter/Convert/FromGsa/Elements/RigidConstraint.cs new file mode 100644 index 00000000..6e8b365e --- /dev/null +++ b/GSA_Adapter/Convert/FromGsa/Elements/RigidConstraint.cs @@ -0,0 +1,101 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +#if GSA_10_1 +using Interop.Gsa_10_1; +#else +using Interop.gsa_8_7; +#endif +using BH.Engine.Serialiser; +using BH.Engine.Adapter; +using BH.oM.Adapters.GSA; +using BH.oM.Structure.Elements; +using BH.oM.Structure.Constraints; +using System.Collections.Generic; +using BH.oM.Adapters.GSA.Elements; +using System; +using System.Linq; + +namespace BH.Adapter.GSA +{ + public static partial class Convert + { + /***************************************************/ + /**** Public Methods ****/ + /***************************************************/ + + public static List FromGsaRigidConstraint(IEnumerable gsaStrings, Dictionary nodes) + { + List constraintList = new List(); + + foreach (string gsaString in gsaStrings) + { + string[] tokens = gsaString.Split(','); + + int primaryNodeName = int.Parse(tokens[2]); + string linkTypeString = tokens[3]; + string[] constrainedNodeNames = tokens[4].Split(','); + + Node primaryNode; + nodes.TryGetValue(primaryNodeName, out primaryNode); + + List constrainedNodes = new List(); + + foreach (string constrainedNodeName in constrainedNodeNames) + { + if (int.TryParse(constrainedNodeName, out int constrainedNodeId)) + { + if (nodes.TryGetValue(constrainedNodeId, out Node constrainedNode)) + constrainedNodes.Add(constrainedNode); + } + } + + RigidConstraintLinkType linkType = RigidConstraintLinkType.ALL; + + if (Enum.TryParse(linkTypeString, out RigidConstraintLinkType parsedLinkType)) + linkType = parsedLinkType; + + RigidConstraint constraint = new RigidConstraint() + { + PrimaryNode = primaryNode, + ConstrainedNodes = constrainedNodes, + Type = linkType + }; + + constraintList.Add(constraint); + } + + return constraintList; + } + + + + + + /***************************************************/ + + } +} + + + + diff --git a/GSA_Adapter/Convert/ToGsa/Elements/RigidConstraint.cs b/GSA_Adapter/Convert/ToGsa/Elements/RigidConstraint.cs new file mode 100644 index 00000000..80c61f56 --- /dev/null +++ b/GSA_Adapter/Convert/ToGsa/Elements/RigidConstraint.cs @@ -0,0 +1,71 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using BH.Engine.Serialiser; +using BH.Engine.Adapter; +using System.Collections.Generic; +using BH.oM.Adapters.GSA; +using BH.oM.Structure.Elements; +using BH.Engine.Adapters.GSA; +using BH.oM.Adapters.GSA.Elements; + +namespace BH.Adapter.GSA +{ + public static partial class Convert + { + /***************************************************/ + /**** Public Methods ****/ + /***************************************************/ + + public static string ToGsaString(this RigidConstraint rigidConstraint) + { + string command = "RIGID.2"; + string name = rigidConstraint.TaggedName().ToGSACleanName(); + + string primaryNode = rigidConstraint.PrimaryNode.GSAId().ToString(); + + List constrainedNodes = rigidConstraint.ConstrainedNodes; + string constrainedNodesIds = ""; + + foreach (Node constrainedNode in constrainedNodes) + { + string id = constrainedNode.GSAId().ToString(); + constrainedNodesIds = constrainedNodesIds + " " + id; + } + + string type = rigidConstraint.Type.ToString(); + + + //RIGID.2 | name | primary_node | type | constrained_nodes | stage + string str = command + ", " + name + ", " + primaryNode + " , " + type + ", " + constrainedNodesIds; + return str; + } + + + /***************************************************/ + + } +} + + + + diff --git a/GSA_Adapter/GSAAdapter.cs b/GSA_Adapter/GSAAdapter.cs index 0c28ffbf..c8bd012f 100644 --- a/GSA_Adapter/GSAAdapter.cs +++ b/GSA_Adapter/GSAAdapter.cs @@ -94,6 +94,7 @@ public GSA87Adapter(string filePath = "", GSAConfig gsaConfig = null, bool activ {typeof(ISurfaceProperty), new List { typeof(IMaterialFragment) } }, {typeof(Spacer), new List { typeof(SpacerProperty), typeof(Node) } }, {typeof(Panel), new List { typeof(ISurfaceProperty), typeof(Node) } }, + {typeof(RigidConstraint), new List { typeof(Node) } }, #if GSA_10_1 {typeof(Node), new List{typeof(Constraint6DOF) } } #endif diff --git a/GSA_Adapter/GSA_Adapter.csproj b/GSA_Adapter/GSA_Adapter.csproj index 19ba8d0b..26b3f3b9 100644 --- a/GSA_Adapter/GSA_Adapter.csproj +++ b/GSA_Adapter/GSA_Adapter.csproj @@ -184,6 +184,7 @@ + @@ -199,6 +200,7 @@ + diff --git a/GSA_oM/Elements/RigidConstraint.cs b/GSA_oM/Elements/RigidConstraint.cs new file mode 100644 index 00000000..f59ec63b --- /dev/null +++ b/GSA_oM/Elements/RigidConstraint.cs @@ -0,0 +1,54 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using BH.oM.Base; +using System; +using System.ComponentModel; +using System.Collections.Generic; +using BH.oM.Quantities.Attributes; +using BH.oM.Structure.Elements; +using BH.oM.Adapters.GSA.SpacerProperties; +using BH.oM.Analytical.Elements; + +namespace BH.oM.Adapters.GSA.Elements +{ + [Description("A rigid constraint defining linkage between nodes.")] + public class RigidConstraint : BHoMObject + { + /***************************************************/ + /**** Properties ****/ + /***************************************************/ + + [Description("Defines the primary node of the rigid constraint.")] + public virtual Node PrimaryNode { get; set; } + + [Description("Defines the constrained nodes of the rigid constraint. Can be a list of nodes.")] + public virtual List ConstrainedNodes { get; set; } + + [Description("Type of rigid constraint.")] + public virtual RigidConstraintLinkType Type { get; set; } = RigidConstraintLinkType.ALL; + + + } +} + + diff --git a/GSA_oM/Enum/RigidConstraintLinkType.cs b/GSA_oM/Enum/RigidConstraintLinkType.cs new file mode 100644 index 00000000..1bfde4ef --- /dev/null +++ b/GSA_oM/Enum/RigidConstraintLinkType.cs @@ -0,0 +1,47 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using System.ComponentModel; + +namespace BH.oM.Adapters.GSA +{ + [Description("Defines type rigid constraint link.")] + public enum RigidConstraintLinkType + { + ALL, + XY_PLANE, + YZ_PLANE, + ZX_PLANE, + XY_PLATE, + YZ_PLATE, + ZX_PLATE, + PIN, + XY_PLANE_PIN, + YZ_PLANE_PIN, + ZX_PLANE_PIN, + XY_PLATE_PIN, + YZ_PLATE_PIN, + ZX_PLATE_PIN + } +} + + diff --git a/GSA_oM/GSA_oM.csproj b/GSA_oM/GSA_oM.csproj index 9d45eecf..93c80c53 100644 --- a/GSA_oM/GSA_oM.csproj +++ b/GSA_oM/GSA_oM.csproj @@ -80,9 +80,11 @@ + + From 5f8b0a0f72f7f66679ec5ce9a4846b0b3dd3cd59 Mon Sep 17 00:00:00 2001 From: Toste Skanberg Dahlstedt Date: Thu, 6 Jul 2023 09:31:47 +0100 Subject: [PATCH 5/9] Redefined how GSA_RigidConstraints are treated, now a part of Structures_RigidLinks. Rigid Constraints are now treated by BHoM as a Rigid Link object but with a fragment that if true tells GSA it is a Rigid Constraints. Removed previously added RigidConstraint Type and ENUM from this PR and instead adjusted the RigidLink methods. Also added more possible LinkConstraint options to the FromGsa - LinkConstraint method. --- GSA_Adapter/CRUD/Create.cs | 48 +++--- GSA_Adapter/CRUD/Read.cs | 19 +-- .../Convert/FromGsa/Elements/RigidLink.cs | 148 +++++++++++++++++- .../FromGsa/Properties/LinkConstraint.cs | 36 ++--- .../Convert/ToGsa/Elements/RigidLink.cs | 108 +++++++++++-- GSA_Adapter/GSAAdapter.cs | 1 - GSA_Adapter/GSA_Adapter.csproj | 2 - GSA_oM/Fragments/GSARigidConstraint.cs | 37 +++++ GSA_oM/GSA_oM.csproj | 3 +- 9 files changed, 331 insertions(+), 71 deletions(-) create mode 100644 GSA_oM/Fragments/GSARigidConstraint.cs diff --git a/GSA_Adapter/CRUD/Create.cs b/GSA_Adapter/CRUD/Create.cs index 5ed01f96..f5061654 100644 --- a/GSA_Adapter/CRUD/Create.cs +++ b/GSA_Adapter/CRUD/Create.cs @@ -160,32 +160,46 @@ private bool CreateObject(ISectionProperty prop) // private bool CreateLinks(IEnumerable links) { - bool success = true; - foreach (RigidLink link in links) - { - success &= ComCall(Convert.ToGsaString(link, GetAdapterId(link).ToString(), 0)); - } foreach (RigidLink link in links) { - List allIds = new List(); - for (int i = 1; i < link.SecondaryNodes.Count; i++) + if (Convert.CheckRigCon(link) == false) { - int id = (int)NextFreeId(link.GetType(), i == 1); - success &= ComCall(Convert.ToGsaString(link, id.ToString(), i)); - allIds.Add(id); + if (link.SecondaryNodes.Count > 1) + { + List secondaryIds = new List(); + foreach (Node secondaryNode in link.SecondaryNodes) + { + int id = (int)NextFreeId(link.GetType(), false); + success &= ComCall(Convert.ToGsaString(link, id.ToString())); + secondaryIds.Add(id); + } + + var allIds = new List { GetAdapterId(link) }; + allIds.AddRange(secondaryIds); + link.Fragments.Remove(typeof(GSAId)); + link.SetAdapterId(typeof(GSAId), allIds); + } + else + { + int id = (int)NextFreeId(link.GetType(), false); + success &= ComCall(Convert.ToGsaString(link, id.ToString())); + link.Fragments.Remove(typeof(GSAId)); + link.SetAdapterId(typeof(GSAId), id); + } } - if (link.SecondaryNodes.Count > 1) + else { - allIds.Insert(0, GetAdapterId(link)); - link.Fragments.Remove(typeof(GSAId)); // to remove the existing single id on the link - link.SetAdapterId(typeof(GSAId), allIds); + success &= ComCall(Convert.ToGsaString(link, GetAdapterId(link).ToString())); } } + return success; } + + /***************************************************/ private bool CreateFEMesh(FEMesh mesh) @@ -280,12 +294,6 @@ private bool CreateObject(FabricPanelProperty fabricProperty) /***************************************************/ - private bool CreateObject(RigidConstraint rigidConstraint) - { - return ComCall(rigidConstraint.ToGsaString()); - } - - /***************************************************/ } } diff --git a/GSA_Adapter/CRUD/Read.cs b/GSA_Adapter/CRUD/Read.cs index 12eb0ab0..018231d7 100644 --- a/GSA_Adapter/CRUD/Read.cs +++ b/GSA_Adapter/CRUD/Read.cs @@ -83,8 +83,6 @@ protected override IEnumerable IRead(Type type, IList indices, Acti return ReadRigidLink(indices as dynamic); if (type == typeof(LinkConstraint)) return ReadLinkConstraint(indices as dynamic); - if (type == typeof(RigidConstraint)) - return ReadRigidConstraint(indices as dynamic); if (type == typeof(FEMesh)) return ReadFEMesh(indices as dynamic); if (type == typeof(ISurfaceProperty)) @@ -406,11 +404,14 @@ public List ReadRigidLink(List ids = null) Dictionary constraints = GetCachedOrReadAsDictionary(); Dictionary nodes = GetCachedOrReadAsDictionary(); + string allConstr = m_gsaCom.GwaCommand("GET_ALL, RIGID").ToString(); + string[] constrArr = string.IsNullOrWhiteSpace(allConstr) ? new string[0] : allConstr.Split('\n'); + int[] potentialBeamRefs = GenerateIndices(ids, typeof(RigidLink)); GsaElement[] gsaElements = new GsaElement[potentialBeamRefs.Length]; m_gsaCom.Elements(potentialBeamRefs, out gsaElements); - return Convert.FromGsaRigidLinks(gsaElements, constraints, nodes); + return Convert.FromGsaRigidLinks(gsaElements, constrArr, constraints, nodes); //if (ids == null) // return proArr.Select(x => Convert.FromGsaSectionProperty(x, materials)).ToList(); @@ -420,18 +421,6 @@ public List ReadRigidLink(List ids = null) /***************************************/ - public List ReadRigidConstraint(List ids = null) - { - string allProps = m_gsaCom.GwaCommand("GET_ALL, RIGID").ToString(); - string[] proArr = string.IsNullOrWhiteSpace(allProps) ? new string[0] : allProps.Split('\n'); - - Dictionary nodes = GetCachedOrReadAsDictionary(); - - return Convert.FromGsaRigidConstraint(proArr, nodes); - } - - /***************************************/ - public List ReadSpacers(List ids = null) { Dictionary nodes = GetCachedOrReadAsDictionary(); diff --git a/GSA_Adapter/Convert/FromGsa/Elements/RigidLink.cs b/GSA_Adapter/Convert/FromGsa/Elements/RigidLink.cs index 473afd01..fe8e2327 100644 --- a/GSA_Adapter/Convert/FromGsa/Elements/RigidLink.cs +++ b/GSA_Adapter/Convert/FromGsa/Elements/RigidLink.cs @@ -31,7 +31,7 @@ using BH.oM.Structure.Elements; using BH.oM.Structure.Constraints; using System.Collections.Generic; - +using System.Linq; namespace BH.Adapter.GSA { @@ -41,10 +41,12 @@ public static partial class Convert /**** Public Methods ****/ /***************************************************/ - public static List FromGsaRigidLinks(IEnumerable gsaElements, Dictionary constraints, Dictionary nodes) + public static List FromGsaRigidLinks(IEnumerable gsaElements, IEnumerable gsaStrings, Dictionary constraints, Dictionary nodes) { + List linkList = new List(); + //Rigid Link foreach (GsaElement gsaLink in gsaElements) { if (gsaLink.eType != 9) @@ -61,8 +63,150 @@ public static List FromGsaRigidLinks(IEnumerable gsaEleme int id = gsaLink.Ref; link.SetAdapterId(typeof(GSAId), id); linkList.Add(link); + } + + //Rigid Constraint + foreach (string gsaString in gsaStrings) + { + string[] tokens = gsaString.Split(','); + + string linkName = tokens[1]; + int primaryNodeName = int.Parse(tokens[2]); + string linkTypeString = tokens[3]; + string[] constrainedNodeNames = tokens[4].Split(','); + + Node primaryNode; + nodes.TryGetValue(primaryNodeName, out primaryNode); + + List constrainedNodes = new List(); + + foreach (string constrainedNodeName in constrainedNodeNames) + { + if (int.TryParse(constrainedNodeName, out int constrainedNodeId)) + { + if (nodes.TryGetValue(constrainedNodeId, out Node constrainedNode)) + constrainedNodes.Add(constrainedNode); + } + } + + LinkConstraint linkType; + + switch (linkTypeString) + { + case "ALL": + linkType = Engine.Structure.Create.LinkConstraintFixed(); + break; + case "PIN": + linkType = Engine.Structure.Create.LinkConstraintPinned(); + break; + case "XY_PLANE": + linkType = Engine.Structure.Create.LinkConstraintXYPlane(); + break; + case "ZX_PLANE": + linkType = Engine.Structure.Create.LinkConstraintZXPlane(); + break; + case "YZ_PLANE": + linkType = Engine.Structure.Create.LinkConstraintYZPlane(); + break; + case "XY_PLANE_PIN": + linkType = Engine.Structure.Create.LinkConstraintXYPlanePin(); + break; + case "ZX_PLANE_PIN": + linkType = Engine.Structure.Create.LinkConstraintZXPlanePin(); + break; + case "YZ_PLANE_PIN": + linkType = Engine.Structure.Create.LinkConstraintYZPlanePin(); + break; + case "XY_PLATE": + linkType = Engine.Structure.Create.LinkConstraintYPlateZPlate(); //Wrong name in engine. Should be just ZPlate. + break; + case "ZX_PLATE": + linkType = Engine.Structure.Create.LinkConstraintYPlate(); + break; + case "YZ_PLATE": + linkType = Engine.Structure.Create.LinkConstraintXPlate(); + break; + case "XY_PLATE_PIN": + linkType = Engine.Structure.Create.LinkConstraintZPlatePin(); + break; + case "ZX_PLATE_PIN": + linkType = Engine.Structure.Create.LinkConstraintYPlatePin(); + break; + case "YZ_PLATE_PIN": + linkType = Engine.Structure.Create.LinkConstraintXPlatePin(); + break; + default: + //String in format example: X:XYY-Y:YZZXX-Z:YY-XX:XX-YY:YY-ZZ:ZZ + linkType = new LinkConstraint(); + string[] constraintProps = linkTypeString.Split('-'); + foreach (string c in constraintProps) + { + string[] fromTo = c.Split(':'); + string from = fromTo[0]; + string to = fromTo[1]; + switch (from) + { + case "X": + if (to.Contains('X')) + linkType.XtoX = true; + if (to.Contains('Y')) + linkType.XtoYY = true; + if (to.Contains('Z')) + linkType.XtoZZ = true; + break; + case "Y": + if (to.Contains('X')) + linkType.YtoXX = true; + if (to.Contains('Y')) + linkType.YtoY = true; + if (to.Contains('Z')) + linkType.YtoZZ = true; + break; + case "Z": + if (to.Contains('X')) + linkType.ZtoXX = true; + if (to.Contains('Y')) + linkType.ZtoYY = true; + if (to.Contains('Z')) + linkType.ZtoZ = true; + break; + case "XX": + if (to.Contains("XX")) + linkType.XXtoXX = true; + break; + case "YY": + if (to.Contains("YY")) + linkType.YYtoYY = true; + break; + case "ZZ": + if (to.Contains("ZZ")) + linkType.ZZtoZZ = true; + break; + } + } + break; + } + + RigidLink link = new RigidLink() + { + PrimaryNode = primaryNode, + SecondaryNodes = constrainedNodes, + Constraint = linkType + }; + + link.ApplyTaggedName(linkName); + + GSARigidConstraint RCtag = new GSARigidConstraint + { + IsRigidConstraint = true + }; + + link.Fragments.Add(RCtag); + + linkList.Add(link); } + return linkList; } diff --git a/GSA_Adapter/Convert/FromGsa/Properties/LinkConstraint.cs b/GSA_Adapter/Convert/FromGsa/Properties/LinkConstraint.cs index b0fa03fa..70d4bd28 100644 --- a/GSA_Adapter/Convert/FromGsa/Properties/LinkConstraint.cs +++ b/GSA_Adapter/Convert/FromGsa/Properties/LinkConstraint.cs @@ -68,24 +68,24 @@ public static LinkConstraint FromGsaLinkConstraint(string gsaProp) case "YZ_PLANE_PIN": constraint = Engine.Structure.Create.LinkConstraintYZPlanePin(); break; - //case "XY_PLATE": - // constraint = BHP.LinkConstraint.ZPlate; - // break; - //case "ZX_PLATE": - // constraint = BHP.LinkConstraint.YPlate; - // break; - //case "YZ_PLATE": - // constraint = BHP.LinkConstraint.YPlate; - // break; //TODO: CHECK CONSTRUCTOR NAMES IN BHOM_ENGINE - //case "XY_PLATE_PIN": - // constraint = BHP.LinkConstraint.ZPlatePin; - // break; - //case "ZX_PLATE_PIN": - // constraint = BHP.LinkConstraint.YPlatePin; - // break; - //case "YZ_PLATE_PIN": - // constraint = BHP.LinkConstraint.ZPlatePin; - // break; + case "XY_PLATE": + constraint = Engine.Structure.Create.LinkConstraintYPlateZPlate(); //TODO: Wrong name in engine. Should be just ZPlate. + break; + case "ZX_PLATE": + constraint = Engine.Structure.Create.LinkConstraintYPlate(); + break; + case "YZ_PLATE": + constraint = Engine.Structure.Create.LinkConstraintXPlate(); + break; + case "XY_PLATE_PIN": + constraint = Engine.Structure.Create.LinkConstraintZPlatePin(); + break; + case "ZX_PLATE_PIN": + constraint = Engine.Structure.Create.LinkConstraintYPlatePin(); + break; + case "YZ_PLATE_PIN": + constraint = Engine.Structure.Create.LinkConstraintXPlatePin(); + break; default: //String in format example: X:XYY-Y:YZZXX-Z:YY-XX:XX-YY:YY-ZZ:ZZ constraint = new LinkConstraint(); diff --git a/GSA_Adapter/Convert/ToGsa/Elements/RigidLink.cs b/GSA_Adapter/Convert/ToGsa/Elements/RigidLink.cs index c9bc1a2f..a8ba923a 100644 --- a/GSA_Adapter/Convert/ToGsa/Elements/RigidLink.cs +++ b/GSA_Adapter/Convert/ToGsa/Elements/RigidLink.cs @@ -25,6 +25,9 @@ using BH.oM.Adapters.GSA; using BH.oM.Structure.Elements; using BH.Engine.Adapters.GSA; +using BH.oM.Base; +using BH.Engine.Base; +using System.Collections.Generic; namespace BH.Adapter.GSA { @@ -36,27 +39,110 @@ public static partial class Convert public static string ToGsaString(this RigidLink link, string index, int secondaryIndex = 0) { - string command = "EL.2"; - string name = link.TaggedName().ToGSACleanName(); - string type = "LINK"; + if (CheckRigCon(link) == false) + { + string command = "EL.2"; + string name = link.TaggedName().ToGSACleanName(); + string type = "LINK"; - string constraintIndex = link.Constraint.GSAId().ToString(); - string group = "0"; + string constraintIndex = link.Constraint.GSAId().ToString(); + string group = "0"; - string startIndex = link.PrimaryNode.GSAId().ToString(); + string startIndex = link.PrimaryNode.GSAId().ToString(); - string endIndex = link.SecondaryNodes[secondaryIndex].GSAId().ToString(); + string endIndex = link.SecondaryNodes[secondaryIndex].GSAId().ToString(); - string dummy = CheckDummy(link); + string dummy = CheckDummy(link); - //EL 1 gfdgfdg NO_RGB LINK 1 1 1 2 0 0 NO_RLS NO_OFFSET DUMMY - string str = command + ", " + index + "," + name + ", NO_RGB , " + type + " , " + constraintIndex + ", " + group + ", " + startIndex + ", " + endIndex + " , 0" + ",0" + ", NO_RLS" + ", NO_OFFSET," + dummy; - return str; + //EL 1 gfdgfdg NO_RGB LINK 1 1 1 2 0 0 NO_RLS NO_OFFSET DUMMY + string str = command + ", " + index + "," + name + ", NO_RGB , " + type + " , " + constraintIndex + ", " + group + ", " + startIndex + ", " + endIndex + " , 0" + ",0" + ", NO_RLS" + ", NO_OFFSET," + dummy; + return str; + } + else { + string command = "RIGID.2"; + string name = link.TaggedName().ToGSACleanName(); + + string primaryNode = link.PrimaryNode.GSAId().ToString(); + + List constrainedNodes = link.SecondaryNodes; + string constrainedNodesIds = ""; + + foreach (Node constrainedNode in constrainedNodes) + { + string id = constrainedNode.GSAId().ToString(); + constrainedNodesIds = constrainedNodesIds + " " + id; + } + + string typename = link.Name.ToString(); + string type; + + switch (typename) + { + case "Fixed": + type = "ALL"; + break; + case "xy-Plane": + type = "XY_PLANE"; + break; + case "yz-Plane": + type = "YZ_PLANE"; + break; + case "zx-Plane": + type = "ZX_PLANE"; + break; + case "z-Plate": + type = "XY_PLATE"; + break; + case "x-Plate": + type = "YZ_PLATE"; + break; + case "y-Plate": + type = "ZX_PLATE"; + break; + case "Pinned": + type = "PIN"; + break; + case "xy-Plane Pin": + type = "XY_PLANE_PIN"; + break; + case "yz-Plane Pin": + type = "YZ_PLANE_PIN"; + break; + case "zx-Plane Pin": + type = "ZX_PLANE_PIN"; + break; + case "z-Plate Pin": + type = "XY_PLATE_PIN"; + break; + case "x-Plate Pin": + type = "YZ_PLATE_PIN"; + break; + case "y-Plate Pin": + type = "ZX_PLATE_PIN"; + break; + default: + type = "All"; + break; + } + + //RIGID.2 | name | primary_node | type | constrained_nodes | stage + string str = command + ", " + name + ", " + primaryNode + " , " + type + ", " + constrainedNodesIds; + return str; + } } /***************************************************/ + public static bool CheckRigCon(BHoMObject obj) + { + GSARigidConstraint tag = obj.FindFragment(); + + if (tag != null && tag.IsRigidConstraint) + return true; + + return false; + } } } diff --git a/GSA_Adapter/GSAAdapter.cs b/GSA_Adapter/GSAAdapter.cs index c8bd012f..0c28ffbf 100644 --- a/GSA_Adapter/GSAAdapter.cs +++ b/GSA_Adapter/GSAAdapter.cs @@ -94,7 +94,6 @@ public GSA87Adapter(string filePath = "", GSAConfig gsaConfig = null, bool activ {typeof(ISurfaceProperty), new List { typeof(IMaterialFragment) } }, {typeof(Spacer), new List { typeof(SpacerProperty), typeof(Node) } }, {typeof(Panel), new List { typeof(ISurfaceProperty), typeof(Node) } }, - {typeof(RigidConstraint), new List { typeof(Node) } }, #if GSA_10_1 {typeof(Node), new List{typeof(Constraint6DOF) } } #endif diff --git a/GSA_Adapter/GSA_Adapter.csproj b/GSA_Adapter/GSA_Adapter.csproj index 26b3f3b9..19ba8d0b 100644 --- a/GSA_Adapter/GSA_Adapter.csproj +++ b/GSA_Adapter/GSA_Adapter.csproj @@ -184,7 +184,6 @@ - @@ -200,7 +199,6 @@ - diff --git a/GSA_oM/Fragments/GSARigidConstraint.cs b/GSA_oM/Fragments/GSARigidConstraint.cs new file mode 100644 index 00000000..330946bf --- /dev/null +++ b/GSA_oM/Fragments/GSARigidConstraint.cs @@ -0,0 +1,37 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + + +using BH.oM.Base; +using System.ComponentModel; + +namespace BH.oM.Adapters.GSA +{ + [Description("Fragment telling whether the element is a Rigid Constraint or Rigid Link")] + public class GSARigidConstraint : IFragment + { + [Description("True means the element will be treated as a rigid constraint in GSA.")] + public virtual bool IsRigidConstraint { get; set; } = false; + } +} + + diff --git a/GSA_oM/GSA_oM.csproj b/GSA_oM/GSA_oM.csproj index 93c80c53..b275e509 100644 --- a/GSA_oM/GSA_oM.csproj +++ b/GSA_oM/GSA_oM.csproj @@ -80,17 +80,16 @@ - - + From c2a79e531bfb7e2cc04388de767c43071cc33f98 Mon Sep 17 00:00:00 2001 From: Peter Nugent Date: Tue, 26 Sep 2023 19:13:48 +0100 Subject: [PATCH 6/9] Fixed statement so links with multiple secondary nodes can be pushed --- GSA_Adapter/CRUD/Create.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/GSA_Adapter/CRUD/Create.cs b/GSA_Adapter/CRUD/Create.cs index f5061654..400ebf22 100644 --- a/GSA_Adapter/CRUD/Create.cs +++ b/GSA_Adapter/CRUD/Create.cs @@ -172,7 +172,8 @@ private bool CreateLinks(IEnumerable links) foreach (Node secondaryNode in link.SecondaryNodes) { int id = (int)NextFreeId(link.GetType(), false); - success &= ComCall(Convert.ToGsaString(link, id.ToString())); + int secondaryIndex = link.SecondaryNodes.IndexOf(secondaryNode); + success &= ComCall(Convert.ToGsaString(link, id.ToString(), secondaryIndex)); secondaryIds.Add(id); } From 871b3f826114424a66c7aeff4fc3b297c7495127 Mon Sep 17 00:00:00 2001 From: Peter Nugent Date: Tue, 26 Sep 2023 22:03:22 +0100 Subject: [PATCH 7/9] Change delimitter for secondary nodes on RigidConstraints --- GSA_Adapter/Convert/FromGsa/Elements/RigidLink.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GSA_Adapter/Convert/FromGsa/Elements/RigidLink.cs b/GSA_Adapter/Convert/FromGsa/Elements/RigidLink.cs index fe8e2327..1a47c57a 100644 --- a/GSA_Adapter/Convert/FromGsa/Elements/RigidLink.cs +++ b/GSA_Adapter/Convert/FromGsa/Elements/RigidLink.cs @@ -73,7 +73,7 @@ public static List FromGsaRigidLinks(IEnumerable gsaEleme string linkName = tokens[1]; int primaryNodeName = int.Parse(tokens[2]); string linkTypeString = tokens[3]; - string[] constrainedNodeNames = tokens[4].Split(','); + string[] constrainedNodeNames = tokens[4].Split(' '); Node primaryNode; nodes.TryGetValue(primaryNodeName, out primaryNode); From a0e4ee9e3c018a6b97df43ab09fd5f4a2c2ad04c Mon Sep 17 00:00:00 2001 From: Peter Nugent Date: Tue, 26 Sep 2023 22:32:53 +0100 Subject: [PATCH 8/9] Change fragment name to IsRigidConstraint to avoid confusion of GSARigidConstraint based on previous comments --- GSA_Adapter/Convert/FromGsa/Elements/RigidLink.cs | 4 ++-- GSA_Adapter/Convert/ToGsa/Elements/RigidLink.cs | 4 ++-- .../{GSARigidConstraint.cs => IsRigidConstraint.cs} | 8 ++++---- GSA_oM/GSA_oM.csproj | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) rename GSA_oM/Fragments/{GSARigidConstraint.cs => IsRigidConstraint.cs} (80%) diff --git a/GSA_Adapter/Convert/FromGsa/Elements/RigidLink.cs b/GSA_Adapter/Convert/FromGsa/Elements/RigidLink.cs index 1a47c57a..8a6feaf1 100644 --- a/GSA_Adapter/Convert/FromGsa/Elements/RigidLink.cs +++ b/GSA_Adapter/Convert/FromGsa/Elements/RigidLink.cs @@ -197,9 +197,9 @@ public static List FromGsaRigidLinks(IEnumerable gsaEleme link.ApplyTaggedName(linkName); - GSARigidConstraint RCtag = new GSARigidConstraint + IsRigidConstraint RCtag = new IsRigidConstraint { - IsRigidConstraint = true + RigidConstraint = true }; link.Fragments.Add(RCtag); diff --git a/GSA_Adapter/Convert/ToGsa/Elements/RigidLink.cs b/GSA_Adapter/Convert/ToGsa/Elements/RigidLink.cs index a8ba923a..8ff41dd4 100644 --- a/GSA_Adapter/Convert/ToGsa/Elements/RigidLink.cs +++ b/GSA_Adapter/Convert/ToGsa/Elements/RigidLink.cs @@ -136,9 +136,9 @@ public static string ToGsaString(this RigidLink link, string index, int secondar public static bool CheckRigCon(BHoMObject obj) { - GSARigidConstraint tag = obj.FindFragment(); + IsRigidConstraint tag = obj.FindFragment(); - if (tag != null && tag.IsRigidConstraint) + if (tag != null && tag.RigidConstraint) return true; return false; diff --git a/GSA_oM/Fragments/GSARigidConstraint.cs b/GSA_oM/Fragments/IsRigidConstraint.cs similarity index 80% rename from GSA_oM/Fragments/GSARigidConstraint.cs rename to GSA_oM/Fragments/IsRigidConstraint.cs index 330946bf..9b04af88 100644 --- a/GSA_oM/Fragments/GSARigidConstraint.cs +++ b/GSA_oM/Fragments/IsRigidConstraint.cs @@ -26,11 +26,11 @@ namespace BH.oM.Adapters.GSA { - [Description("Fragment telling whether the element is a Rigid Constraint or Rigid Link")] - public class GSARigidConstraint : IFragment + [Description("A fragment to identify whether the RigidLink is a Constraint or Link (i.e. element) in GSA.")] + public class IsRigidConstraint : IFragment { - [Description("True means the element will be treated as a rigid constraint in GSA.")] - public virtual bool IsRigidConstraint { get; set; } = false; + [Description("True means the RigidLink will be treated as a Rigid Constraint in GSA, false means it will be treated as a Link.")] + public virtual bool RigidConstraint { get; set; } = false; } } diff --git a/GSA_oM/GSA_oM.csproj b/GSA_oM/GSA_oM.csproj index b275e509..83bd4ecc 100644 --- a/GSA_oM/GSA_oM.csproj +++ b/GSA_oM/GSA_oM.csproj @@ -89,7 +89,7 @@ - + From 48c8b6bf546de0c9a05d4c70dd0c864ba8ab0547 Mon Sep 17 00:00:00 2001 From: BHoMBot Date: Fri, 3 Nov 2023 14:34:50 +0000 Subject: [PATCH 9/9] Update readme links and references --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4514274a..51537451 100644 --- a/README.md +++ b/README.md @@ -26,12 +26,12 @@ Grab the [latest installer](https://bhom.xyz/) and a selection of [sample script ## Getting Started for Developers 🤖 If you want to build the BHoM and the Toolkits from source, it's hopefully easy! 😄 -Do take a look at our specific wiki pages here: [Getting Started for Developers](https://github.com/BHoM/documentation/wiki/Getting-started-for-developers) +Do take a look at our specific wiki pages here: [Getting Started for Developers](https://bhom.xyz/documentation/Contributing/Getting-started-for-developers/) ## Want to Contribute? ## -BHoM is an open-source project and would be nothing without its community. Take a look at our contributing guidelines and tips [here](https://github.com/BHoM/BHoM/blob/master/CONTRIBUTING.md). +BHoM is an open-source project and would be nothing without its community. Take a look at our contributing guidelines and tips [here](https://github.com/BHoM/BHoM/blob/main/CONTRIBUTING.md). ## Licence ## @@ -39,5 +39,5 @@ BHoM is an open-source project and would be nothing without its community. Take BHoM is free software licenced under GNU Lesser General Public Licence - [https://www.gnu.org/licenses/lgpl-3.0.html](https://www.gnu.org/licenses/lgpl-3.0.html) Each contributor holds copyright over their respective contributions. The project versioning (Git) records all such contribution source information. -See [LICENSE](https://github.com/BHoM/BHoM/blob/master/LICENSE) and [COPYRIGHT_HEADER](https://github.com/BHoM/BHoM/blob/master/COPYRIGHT_HEADER.txt). +See [LICENSE](https://github.com/BHoM/BHoM/blob/main/LICENSE) and [COPYRIGHT_HEADER](https://github.com/BHoM/BHoM/blob/main/COPYRIGHT_HEADER.txt).