From 3c4e694b5acf3a553a3bdfbda41bda4e3c5cb0c0 Mon Sep 17 00:00:00 2001 From: Isak Naslund Date: Thu, 19 Jan 2023 11:00:25 +0100 Subject: [PATCH 1/5] Update to make sue of caching system added in https://github.com/BHoM/BHoM_Adapter/pull/337 Also includes a tweak to read of materials to aim to make it fit with new system. ID for materials for GSA10 now includes material type, as that is required to differentiate between different material types --- GSA_Adapter/CRUD/Read.cs | 91 ++++++------------- GSA_Adapter/Convert/FromGsa/Elements/Bar.cs | 16 ++-- .../Convert/FromGsa/Elements/FEMesh.cs | 6 +- .../Convert/FromGsa/Elements/RigidLink.cs | 16 ++-- .../Convert/FromGsa/Elements/Spacer.cs | 12 +-- .../Convert/FromGsa/Loads/LoadCombination.cs | 4 +- .../Convert/FromGsa/Properties/Material.cs | 7 +- 7 files changed, 60 insertions(+), 92 deletions(-) diff --git a/GSA_Adapter/CRUD/Read.cs b/GSA_Adapter/CRUD/Read.cs index 3147533e..463eea92 100644 --- a/GSA_Adapter/CRUD/Read.cs +++ b/GSA_Adapter/CRUD/Read.cs @@ -105,27 +105,7 @@ protected override IEnumerable IRead(Type type, IList indices, Acti public List ReadMaterials(List ids = null) { - return ReadMaterials(ids, false); - } - - /***************************************************/ - - public List ReadMaterials(List ids = null, bool includeStandard = false) - { - List materials = ReadMaterialDictionary(ids, includeStandard).Select(x => x.Value).ToList(); - - if (ids != null && ids.Count != 0) - materials = materials.Where(x => ids.Contains(x.GSAId().ToString())).ToList(); - - return materials; - } - - public Dictionary ReadMaterialDictionary(List ids = null, bool includeStandard = false) - { - //List materials = ReadMaterials(null, false); List materials = new List(); - List keys = new List(); - Dictionary materialDictionary = new Dictionary(); #if GSA_10_1 string allProps = m_gsaCom.GwaCommand("GET_ALL, MAT_ANAL.1").ToString(); @@ -148,24 +128,22 @@ public Dictionary ReadMaterialDictionary(List else materials = matArr.Where(x => ids.Contains(x.Split(',')[1])).Select(x => Convert.FromGsaMaterial(x)).Where(x => x != null).ToList(); - if (includeStandard) - materials.AddRange(GetStandardGsaMaterials()); + return materials; + } + + /***************************************************/ - for (int i = 0; i < materials.Count(); i++) + public Dictionary ReadMaterialDictionary(List ids = null, bool includeStandard = false) + { + Dictionary materials = GetCachedOrReadAsDictionary(ids); + if (includeStandard) { -#if GSA_10_1 - string key = matArr[i].Split(("_.").ToCharArray())[1] + ":" + materials[i].GSAId(); -#else - string key = GetAdapterId(materials[i]).ToString(); -#endif - if (!keys.Contains(key)) + foreach (IMaterialFragment standardMaterial in GetStandardGsaMaterials()) { - keys.Add(key); - materialDictionary.Add(key, materials[i]); + materials[standardMaterial.Name] = standardMaterial; } } - - return materialDictionary; + return materials; } /***************************************************/ @@ -189,22 +167,16 @@ public List ReadLoadCases(List ids = null) public List ReadBars(List ids = null) { - //int[] potentialBeamRefs = GenerateIndices(ids, typeof(Bar)); - - //GsaElement[] gsaElements = new GsaElement[potentialBeamRefs.Length]; - //m_gsaCom.Elements(potentialBeamRefs, out gsaElements); #if GSA_10_1 - string allNodes = m_gsaCom.GwaCommand("GET_ALL, EL.4").ToString(); + string allBars = m_gsaCom.GwaCommand("GET_ALL, EL.4").ToString(); #else - string allNodes = m_gsaCom.GwaCommand("GET_ALL, EL.2").ToString(); + string allBars = m_gsaCom.GwaCommand("GET_ALL, EL.2").ToString(); #endif - string[] barArr = string.IsNullOrWhiteSpace(allNodes) ? new string[0] : allNodes.Split('\n'); + string[] barArr = string.IsNullOrWhiteSpace(allBars) ? new string[0] : allBars.Split('\n'); - List secPropList = ReadSectionProperties(); - List nodeList = ReadNodes(); - Dictionary secProps = secPropList.Where(x => x != null).ToDictionary(x => GetAdapterId(x).ToString()); - Dictionary nodes = nodeList.ToDictionary(x => GetAdapterId(x).ToString()); + Dictionary secProps = GetCachedOrReadAsDictionary(); + Dictionary nodes = GetCachedOrReadAsDictionary(); return Convert.FromGsaBars(barArr, secProps, nodes, ids); } @@ -224,8 +196,7 @@ public List ReadLoadCombinations(List ids = null) analList.Add(anal); } - List lCaseList = ReadLoadCases(); - Dictionary lCases = lCaseList.ToDictionary(x => x.Number.ToString()); + Dictionary lCases = GetCachedOrReadAsDictionary(); if (ids == null) lComabinations = analList.Select(x => Convert.FromGsaAnalTask(x, lCases)).ToList(); @@ -366,11 +337,8 @@ public List ReadFEMesh(List ids = null) GsaElement[] gsaElements = new GsaElement[potentialMeshRefs.Length]; m_gsaCom.Elements(potentialMeshRefs, out gsaElements); - List secPropList = ReadProperty2d(); - List nodeList = ReadNodes(); - - Dictionary props = secPropList.Where(x => x != null).ToDictionary(x => GetAdapterId(x).ToString()); - Dictionary nodes = nodeList.ToDictionary(x => GetAdapterId(x).ToString()); + Dictionary props = GetCachedOrReadAsDictionary(); + Dictionary nodes = GetCachedOrReadAsDictionary(); return Convert.FromGsaFEMesh(gsaElements, props, nodes); } @@ -392,11 +360,8 @@ public List ReadLinkConstraint(List ids = null) public List ReadRigidLink(List ids = null) { - List constraintList = ReadLinkConstraint(null); - List nodeList = ReadNodes(); - - Dictionary constraints = constraintList.ToDictionary(x => GetAdapterId(x).ToString()); - Dictionary nodes = nodeList.ToDictionary(x => GetAdapterId(x).ToString()); + Dictionary constraints = GetCachedOrReadAsDictionary(); + Dictionary nodes = GetCachedOrReadAsDictionary(); int[] potentialBeamRefs = GenerateIndices(ids, typeof(RigidLink)); GsaElement[] gsaElements = new GsaElement[potentialBeamRefs.Length]; @@ -414,19 +379,14 @@ public List ReadRigidLink(List ids = null) public List ReadSpacers(List ids = null) { - List nodeList = ReadNodes(); - List spacerProps = ReadSpacerProperties(); - - Dictionary nodes = nodeList.ToDictionary(x => GetAdapterId(x).ToString()); - Dictionary secProps = spacerProps.Where(x => x != null).ToDictionary(x => GetAdapterId(x).ToString()); + Dictionary nodes = GetCachedOrReadAsDictionary(); + Dictionary secProps = GetCachedOrReadAsDictionary(); int[] potentialBeamRefs = GenerateIndices(ids, typeof(Spacer)); GsaElement[] gsaElements = new GsaElement[potentialBeamRefs.Length]; m_gsaCom.Elements(potentialBeamRefs, out gsaElements); return Convert.FromGsaSpacers(gsaElements, secProps, nodes); - - } /***************************************/ @@ -469,6 +429,7 @@ private int[] GenerateIndices(List ids, Type elementType) private List GetStandardGsaMaterials() { +#if !GSA_10_1 List materials = new List(); materials.Add(new Steel() { Name = "STEEL" }); materials.Add(new Concrete() { Name = "CONC_SHORT" }); @@ -481,6 +442,10 @@ private List GetStandardGsaMaterials() } return materials; +#else + return new List(); +#endif + } /***************************************************/ diff --git a/GSA_Adapter/Convert/FromGsa/Elements/Bar.cs b/GSA_Adapter/Convert/FromGsa/Elements/Bar.cs index 18f6f732..c5ea7b39 100644 --- a/GSA_Adapter/Convert/FromGsa/Elements/Bar.cs +++ b/GSA_Adapter/Convert/FromGsa/Elements/Bar.cs @@ -43,7 +43,7 @@ public static partial class Convert /**** Public Methods ****/ /***************************************************/ - public static List FromGsaBars(IEnumerable gsaElements, Dictionary secProps, Dictionary nodes) + public static List FromGsaBars(IEnumerable gsaElements, Dictionary secProps, Dictionary nodes) { List barList = new List(); @@ -71,8 +71,8 @@ public static List FromGsaBars(IEnumerable gsaElements, Diction } Node n1, n2; - nodes.TryGetValue(gsaBar.Topo[0].ToString(), out n1); - nodes.TryGetValue(gsaBar.Topo[1].ToString(), out n2); + nodes.TryGetValue(gsaBar.Topo[0], out n1); + nodes.TryGetValue(gsaBar.Topo[1], out n2); Bar bar = new Bar { StartNode = n1, EndNode = n2 }; bar.ApplyTaggedName(gsaBar.Name); @@ -82,7 +82,7 @@ public static List FromGsaBars(IEnumerable gsaElements, Diction bar.OrientationAngle = gsaBar.Beta; ISectionProperty prop; - secProps.TryGetValue(gsaBar.Property.ToString(), out prop); + secProps.TryGetValue(gsaBar.Property, out prop); bar.SectionProperty = prop; @@ -97,7 +97,7 @@ public static List FromGsaBars(IEnumerable gsaElements, Diction /***************************************************/ - public static List FromGsaBars(IEnumerable gsaStrings, Dictionary secProps, Dictionary nodes, List ids) + public static List FromGsaBars(IEnumerable gsaStrings, Dictionary secProps, Dictionary nodes, List ids) { List barList = new List(); @@ -135,15 +135,15 @@ public static List FromGsaBars(IEnumerable gsaStrings, Dictionary 10) diff --git a/GSA_Adapter/Convert/FromGsa/Elements/FEMesh.cs b/GSA_Adapter/Convert/FromGsa/Elements/FEMesh.cs index c5b749e1..bfe88e58 100644 --- a/GSA_Adapter/Convert/FromGsa/Elements/FEMesh.cs +++ b/GSA_Adapter/Convert/FromGsa/Elements/FEMesh.cs @@ -41,7 +41,7 @@ public static partial class Convert /**** Public Methods ****/ /***************************************************/ - public static List FromGsaFEMesh(IEnumerable gsaElements, Dictionary props, Dictionary nodes) + public static List FromGsaFEMesh(IEnumerable gsaElements, Dictionary props, Dictionary nodes) { List meshList = new List(); @@ -61,12 +61,12 @@ public static List FromGsaFEMesh(IEnumerable gsaElements, Di FEMeshFace face = new FEMeshFace() { NodeListIndices = Enumerable.Range(0, gsaMesh.NumTopo).ToList(), OrientationAngle = gsaMesh.Beta * System.Math.PI / 180 }; face.SetAdapterId(typeof(GSAId), id); ISurfaceProperty property; - props.TryGetValue(gsaMesh.Property.ToString(), out property); + props.TryGetValue(gsaMesh.Property, out property); FEMesh mesh = new FEMesh() { Faces = new List() { face }, - Nodes = gsaMesh.Topo.Select(x => nodes[x.ToString()]).ToList(), + Nodes = gsaMesh.Topo.Select(x => nodes[x]).ToList(), Property = property }; diff --git a/GSA_Adapter/Convert/FromGsa/Elements/RigidLink.cs b/GSA_Adapter/Convert/FromGsa/Elements/RigidLink.cs index 3dc2c76d..473afd01 100644 --- a/GSA_Adapter/Convert/FromGsa/Elements/RigidLink.cs +++ b/GSA_Adapter/Convert/FromGsa/Elements/RigidLink.cs @@ -41,7 +41,7 @@ public static partial class Convert /**** Public Methods ****/ /***************************************************/ - public static List FromGsaRigidLinks(IEnumerable gsaElements, Dictionary constraints, Dictionary nodes) + public static List FromGsaRigidLinks(IEnumerable gsaElements, Dictionary constraints, Dictionary nodes) { List linkList = new List(); @@ -50,17 +50,17 @@ public static List FromGsaRigidLinks(IEnumerable gsaEleme if (gsaLink.eType != 9) continue; - RigidLink face = new RigidLink() + RigidLink link = new RigidLink() { - PrimaryNode = nodes[gsaLink.Topo[0].ToString()], - SecondaryNodes = new List { nodes[gsaLink.Topo[1].ToString()] }, - Constraint = constraints[gsaLink.Property.ToString()] + PrimaryNode = nodes[gsaLink.Topo[0]], + SecondaryNodes = new List { nodes[gsaLink.Topo[1]] }, + Constraint = constraints[gsaLink.Property] }; - face.ApplyTaggedName(gsaLink.Name); + link.ApplyTaggedName(gsaLink.Name); int id = gsaLink.Ref; - face.SetAdapterId(typeof(GSAId), id); - linkList.Add(face); + link.SetAdapterId(typeof(GSAId), id); + linkList.Add(link); } return linkList; diff --git a/GSA_Adapter/Convert/FromGsa/Elements/Spacer.cs b/GSA_Adapter/Convert/FromGsa/Elements/Spacer.cs index 38686c75..5ed0fd65 100644 --- a/GSA_Adapter/Convert/FromGsa/Elements/Spacer.cs +++ b/GSA_Adapter/Convert/FromGsa/Elements/Spacer.cs @@ -46,7 +46,7 @@ public static partial class Convert /**** Public Methods ****/ /***************************************************/ - public static List FromGsaSpacers(IEnumerable gsaElements, Dictionary spaProps, Dictionary nodes) + public static List FromGsaSpacers(IEnumerable gsaElements, Dictionary spaProps, Dictionary nodes) { List spacerList = new List(); @@ -56,16 +56,14 @@ public static List FromGsaSpacers(IEnumerable gsaElements, D continue; Node n1, n2; - nodes.TryGetValue(gsaSpacer.Topo[0].ToString(), out n1); - nodes.TryGetValue(gsaSpacer.Topo[1].ToString(), out n2); + nodes.TryGetValue(gsaSpacer.Topo[0], out n1); + nodes.TryGetValue(gsaSpacer.Topo[1], out n2); Spacer spacer = new Spacer { StartNode = n1, EndNode = n2 }; spacer.ApplyTaggedName(gsaSpacer.Name); - - - SpacerProperty prop; - spaProps.TryGetValue(gsaSpacer.Property.ToString(), out prop); + SpacerProperty prop; + spaProps.TryGetValue(gsaSpacer.Property, out prop); spacer.SpacerProperty = prop; diff --git a/GSA_Adapter/Convert/FromGsa/Loads/LoadCombination.cs b/GSA_Adapter/Convert/FromGsa/Loads/LoadCombination.cs index 2aa9d865..b12df4d8 100644 --- a/GSA_Adapter/Convert/FromGsa/Loads/LoadCombination.cs +++ b/GSA_Adapter/Convert/FromGsa/Loads/LoadCombination.cs @@ -36,7 +36,7 @@ public static partial class Convert /**** Public Methods ****/ /***************************************************/ - public static LoadCombination FromGsaAnalTask(string gsaString, Dictionary lCases) + public static LoadCombination FromGsaAnalTask(string gsaString, Dictionary lCases) { if (string.IsNullOrWhiteSpace(gsaString)) @@ -61,7 +61,7 @@ public static LoadCombination FromGsaAnalTask(string gsaString, Dictionary Date: Fri, 20 Jan 2023 16:24:40 +0100 Subject: [PATCH 2/5] Add special case for update for materials for GSA10 --- GSA_Adapter/CRUD/Update.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/GSA_Adapter/CRUD/Update.cs b/GSA_Adapter/CRUD/Update.cs index 626c3ac0..e967967c 100644 --- a/GSA_Adapter/CRUD/Update.cs +++ b/GSA_Adapter/CRUD/Update.cs @@ -27,6 +27,8 @@ using BH.Engine.Adapter; using BH.oM.Adapters.GSA; using BH.Engine.Adapters.GSA; +using BH.oM.Structure.MaterialFragments; +using System.Linq; namespace BH.Adapter.GSA { @@ -73,6 +75,19 @@ private bool Update(IEnumerable objects, ActionConfig actionConfig = nul } /***************************************************/ + +#if GSA_10_1 + private bool Update(IEnumerable materials, ActionConfig actionConfig = null) + { + bool success = true; + foreach (IMaterialFragment material in materials) + { + string index = this.GetAdapterId(material).Split(':').FirstOrDefault(); + success &= ComCall(Convert.IToGsaString(material, index)); + } + return success; + } +#endif } } From 5b28087d9500899de64886bb6839509ea34fda04 Mon Sep 17 00:00:00 2001 From: Isak Naslund Date: Mon, 23 Jan 2023 11:30:15 +0100 Subject: [PATCH 3/5] Make sure same material is only converted once --- GSA_Adapter/CRUD/Read.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GSA_Adapter/CRUD/Read.cs b/GSA_Adapter/CRUD/Read.cs index 463eea92..79911248 100644 --- a/GSA_Adapter/CRUD/Read.cs +++ b/GSA_Adapter/CRUD/Read.cs @@ -121,7 +121,7 @@ public List ReadMaterials(List ids = null) string allProps = m_gsaCom.GwaCommand("GET_ALL, MAT").ToString(); #endif string[] matArr = string.IsNullOrWhiteSpace(allProps) ? new string[0] : allProps.Split('\n'); - matArr = matArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToArray(); + matArr = matArr.Where(x => !string.IsNullOrWhiteSpace(x)).Distinct().ToArray(); if (ids == null) materials = matArr.Select(x => Convert.FromGsaMaterial(x)).Where(x => x != null).ToList(); From a01006d12b8aa4822abed909ff64934f9b17969d Mon Sep 17 00:00:00 2001 From: Isak Naslund Date: Mon, 23 Jan 2023 11:32:38 +0100 Subject: [PATCH 4/5] Material handling Update various parts of the material handling to fit with the new framework. Main fixes to make sure ids of materials are set as "MaterialType:Number" for GSA 10, as GSA 10 has multiple material tables --- GSA_Adapter/CRUD/Create.cs | 8 +++++-- GSA_Adapter/CRUD/Update.cs | 3 +-- .../Convert/FromGsa/Properties/Material.cs | 10 +++++---- .../Convert/ToGsa/Properties/Material.cs | 22 +++++++++++++++---- .../ToGsa/Properties/SectionProperty.cs | 3 +-- .../ToGsa/Properties/SurfaceProperties.cs | 4 ++-- GSA_Adapter/Convert/ToGsa/_ToGsa.cs | 8 ++++--- 7 files changed, 39 insertions(+), 19 deletions(-) diff --git a/GSA_Adapter/CRUD/Create.cs b/GSA_Adapter/CRUD/Create.cs index 1983234c..94dfb9d3 100644 --- a/GSA_Adapter/CRUD/Create.cs +++ b/GSA_Adapter/CRUD/Create.cs @@ -75,13 +75,15 @@ protected override bool ICreate(IEnumerable objects, ActionConfig actionCo /***************************************************/ +#if GSA_10_1 private bool CreateMaterials(IEnumerable materials) { bool success = true; foreach (IMaterialFragment material in materials) { - int index = m_gsaCom.GwaCommand("HIGHEST, " + Convert.ToGsaString(material.GetType())) + 1; - this.SetAdapterId(material, index); + string type = Convert.ToGsaString(material.GetType()); + int index = m_gsaCom.GwaCommand("HIGHEST, " + type) + 1; + this.SetAdapterId(material, $"{type.Split('_').Last()}:{index}"); success &= ComCall(Convert.IToGsaString(material, index.ToString())); } return success; @@ -89,6 +91,8 @@ private bool CreateMaterials(IEnumerable materials) /***************************************************/ +#endif + private bool CreateObject(BH.oM.Base.IBHoMObject obj) { return ComCall(Convert.IToGsaString(obj, GetAdapterId(obj).ToString())); diff --git a/GSA_Adapter/CRUD/Update.cs b/GSA_Adapter/CRUD/Update.cs index e967967c..6c8821c1 100644 --- a/GSA_Adapter/CRUD/Update.cs +++ b/GSA_Adapter/CRUD/Update.cs @@ -82,8 +82,7 @@ private bool Update(IEnumerable materials, ActionConfig actio bool success = true; foreach (IMaterialFragment material in materials) { - string index = this.GetAdapterId(material).Split(':').FirstOrDefault(); - success &= ComCall(Convert.IToGsaString(material, index)); + success &= ComCall(Convert.IToGsaString(material, material.MaterialId())); } return success; } diff --git a/GSA_Adapter/Convert/FromGsa/Properties/Material.cs b/GSA_Adapter/Convert/FromGsa/Properties/Material.cs index bb7c7788..a60a892e 100644 --- a/GSA_Adapter/Convert/FromGsa/Properties/Material.cs +++ b/GSA_Adapter/Convert/FromGsa/Properties/Material.cs @@ -116,14 +116,16 @@ public static IMaterialFragment FromGsaMaterial(string gsaString) return null; } - string id = gStr[1]; + #if GSA_10_1 + string id = gStr[1]; id = gsaString.Split(("_.").ToCharArray())[1] + ":" + id; + mat.SetAdapterId(typeof(GSAId), id); +#else + int id = int.Parse(gStr[1]); + mat.SetAdapterId(typeof(GSAId), id); #endif - - mat.SetAdapterId(typeof(GSAId),id); - return mat; } diff --git a/GSA_Adapter/Convert/ToGsa/Properties/Material.cs b/GSA_Adapter/Convert/ToGsa/Properties/Material.cs index a8a459a6..dec90151 100644 --- a/GSA_Adapter/Convert/ToGsa/Properties/Material.cs +++ b/GSA_Adapter/Convert/ToGsa/Properties/Material.cs @@ -211,16 +211,28 @@ private static void MaterialIdentifiers(this IMaterialFragment material, out str if (material.GetMaterialType() == "UNDEF" || material is Aluminium) //Aluminium current unsuported in the GSA API { - analNum = material.GSAId().ToString(); + analNum = material.MaterialId(); } else { - matNum = material.GSAId().ToString(); + matNum = material.MaterialId(); materialType = material.GetMaterialType(); } } + /***************************************************/ + +#endif + public static string MaterialId(this IMaterialFragment material) + { +#if GSA_10_1 + return material.AdapterId(typeof(GSAId)).Split(':').Last(); +#else + return material.GSAId().ToString(); #endif + } + + /***************************************************/ private static string CommaSeparatedValues(Vector v) { @@ -238,8 +250,10 @@ private static string GetMaterialType(this IMaterialFragment material) return "CONCRETE"; else if (material is Aluminium) return "ALUMINIUM"; - else if (material is Timber) - return "TIMBER"; + else if (material is Fabric) + return "FABRIC"; + //else if (material is Timber) + // return "TIMBER"; else return "UNDEF"; #else diff --git a/GSA_Adapter/Convert/ToGsa/Properties/SectionProperty.cs b/GSA_Adapter/Convert/ToGsa/Properties/SectionProperty.cs index 6b2fa82e..bf38a505 100644 --- a/GSA_Adapter/Convert/ToGsa/Properties/SectionProperty.cs +++ b/GSA_Adapter/Convert/ToGsa/Properties/SectionProperty.cs @@ -60,8 +60,6 @@ private static string ToGsaString(this ISectionProperty prop, string index, stri prop.Name = prop.DescriptionOrName().ToGSACleanName(); string name = prop.TaggedName(); - string mat = prop.Material.GSAId().ToString();// materialId; //"STEEL";// material.Name; - string colour = "NO_RGB"; string principle = "NO"; string type = prop.SectionType(); @@ -81,6 +79,7 @@ private static string ToGsaString(this ISectionProperty prop, string index, stri //SECTION.7 | ref | colour | name | memb | pool | point | refY | refZ | mass | fraction | cost | left | right | slab | num { } string str = "SECTION.7," + index + "," + colour + "," + name + ",1D_GENERIC,0,CENTROID,0,0,0,1,0,0,0,0,1," + sectionComp + "," + prop.ISectionMaterialComp(); #else + string mat = prop.Material.GSAId().ToString();// materialId; //"STEEL";// material.Name; string str = "PROP_SEC" + "," + index + "," + name + "," + colour + "," + mat + "," + description + "," + principle + "," + type + "," + cost + "," + props + "," + mods + "," + plate_type + "," + calc_J; #endif return str; diff --git a/GSA_Adapter/Convert/ToGsa/Properties/SurfaceProperties.cs b/GSA_Adapter/Convert/ToGsa/Properties/SurfaceProperties.cs index 2df11335..3cb6c28b 100644 --- a/GSA_Adapter/Convert/ToGsa/Properties/SurfaceProperties.cs +++ b/GSA_Adapter/Convert/ToGsa/Properties/SurfaceProperties.cs @@ -46,7 +46,6 @@ private static string ToGsaString(ConstantThickness panProp, string index) { panProp.Name = panProp.DescriptionOrName().ToGSACleanName(); string name = panProp.TaggedName(); - string mat = panProp.Material.GSAId().ToString(); string command = "PROP_2D"; string colour = "NO_RGB"; @@ -83,6 +82,7 @@ private static string ToGsaString(ConstantThickness panProp, string index) //PROP_2D.7 | num | name | colour | type | axis | mat | mat_type | grade | design | profile | ref_pt | ref_z | mass | flex | shear | inplane | weight | return $"PROP_2D.7, {index}, {name}, {colour}, {type}, {axis}, {analNum}, {materialType}, {matNum}, {design}, {thick}, {ref_pt}, {ref_z}, {mass}, {bending}, {shear}, {inplane}, {weight}"; #else + string mat = panProp.Material.GSAId().ToString(); return command + "," + index + "," + name + "," + colour + "," + axis + "," + mat + "," + type + "," + thick + "," + weight + "," + mass + "," + bending + "," + inplane; #endif } @@ -119,7 +119,7 @@ public static List ToGsaStrings(this FabricPanelProperty panProp, string string name = panProp.TaggedName(); string colour = "NO_RGB"; string axis = "GLOBAL"; - string mat = panProp.Material.GSAId().ToString(); + string mat = panProp.Material.MaterialId(); string type = "FABRIC"; string thick = "0.1"; string mass = panProp.AdditionalMass.ToString(); diff --git a/GSA_Adapter/Convert/ToGsa/_ToGsa.cs b/GSA_Adapter/Convert/ToGsa/_ToGsa.cs index 8a5bc939..ea928623 100644 --- a/GSA_Adapter/Convert/ToGsa/_ToGsa.cs +++ b/GSA_Adapter/Convert/ToGsa/_ToGsa.cs @@ -34,7 +34,7 @@ using BH.oM.Adapters.GSA.SpacerProperties; using BH.oM.Adapters.GSA.Elements; using BH.oM.Base.Attributes; - +using BH.oM.Adapters.GSA.MaterialFragments; namespace BH.Adapter.GSA { @@ -56,9 +56,11 @@ public static string ToGsaString(this Type type) else if (type == typeof(Concrete)) return "MAT_CONCRETE"; else if (type == typeof(Timber)) - return "MAT_TIMBER"; + return "MAT_ANAL";//return "MAT_TIMBER"; else if (type == typeof(Aluminium)) - return "MAT_ALUMINIUM"; + return "MAT_ANAL";//return "MAT_ALUMINIUM"; + else if (type == typeof(Fabric)) + return "MAT_FABRIC";//return "MAT_ALUMINIUM"; else if (type == typeof(GenericIsotropicMaterial) || type == typeof(GenericOrthotropicMaterial)) return "MAT_ANAL"; #else From d377fae5fb3c3c073550cab08ac0ef1699b07da3 Mon Sep 17 00:00:00 2001 From: Isak Naslund Date: Tue, 24 Jan 2023 16:20:10 +0100 Subject: [PATCH 5/5] Update read material dictionary for GSA 8.7 --- GSA_Adapter/CRUD/Read.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/GSA_Adapter/CRUD/Read.cs b/GSA_Adapter/CRUD/Read.cs index 79911248..662d9b2e 100644 --- a/GSA_Adapter/CRUD/Read.cs +++ b/GSA_Adapter/CRUD/Read.cs @@ -135,7 +135,11 @@ public List ReadMaterials(List ids = null) public Dictionary ReadMaterialDictionary(List ids = null, bool includeStandard = false) { +#if GSA_10_1 Dictionary materials = GetCachedOrReadAsDictionary(ids); +#else + Dictionary materials = GetCachedOrReadAsDictionary(ids?.Select(x => int.Parse(x)).ToList()).ToDictionary(x => x.Key.ToString(), x => x.Value); +#endif if (includeStandard) { foreach (IMaterialFragment standardMaterial in GetStandardGsaMaterials())