diff --git a/Etabs_Adapter/CRUD/Create/Link.cs b/Etabs_Adapter/CRUD/Create/Link.cs index 8d27f83a..6342b5f5 100644 --- a/Etabs_Adapter/CRUD/Create/Link.cs +++ b/Etabs_Adapter/CRUD/Create/Link.cs @@ -24,6 +24,7 @@ using System.Linq; using BH.oM.Structure.Elements; using BH.oM.Structure.Constraints; +using BH.Engine.Structure; #if Debug17 || Release17 using ETABSv17; #elif Debug18 || Release18 @@ -60,7 +61,7 @@ private bool CreateObject(RigidLink bhLink) { string name = ""; - retA = m_model.LinkObj.AddByPoint(masterNode.CustomData[AdapterIdName].ToString(), slaveNodes[i].CustomData[AdapterIdName].ToString(), ref name, false, constraint.Name); + retA = m_model.LinkObj.AddByPoint(masterNode.CustomData[AdapterIdName].ToString(), slaveNodes[i].CustomData[AdapterIdName].ToString(), ref name, false, constraint.DescriptionOrName()); linkIds.Add(name); } @@ -75,7 +76,7 @@ private bool CreateObject(RigidLink bhLink) private bool CreateObject(LinkConstraint bhLinkConstraint) { - string name = bhLinkConstraint.Name; + string name = bhLinkConstraint.DescriptionOrName(); bool[] dof = new bool[6]; diff --git a/Etabs_Adapter/CRUD/Create/Material.cs b/Etabs_Adapter/CRUD/Create/Material.cs index 0870b922..82c3b37c 100644 --- a/Etabs_Adapter/CRUD/Create/Material.cs +++ b/Etabs_Adapter/CRUD/Create/Material.cs @@ -56,14 +56,14 @@ private bool CreateObject(IMaterialFragment material) string guid = ""; string notes = ""; string name = ""; - if (m_model.PropMaterial.GetMaterial(material.Name, ref matType, ref colour, ref notes, ref guid) != 0) + if (m_model.PropMaterial.GetMaterial(material.DescriptionOrName(), ref matType, ref colour, ref notes, ref guid) != 0) { m_model.PropMaterial.AddMaterial(ref name, MaterialTypeToCSI(material.IMaterialType()), "", "", ""); - m_model.PropMaterial.ChangeName(name, material.Name); + m_model.PropMaterial.ChangeName(name, material.DescriptionOrName()); if (material is IIsotropic) { IIsotropic isotropic = material as IIsotropic; - success &= m_model.PropMaterial.SetMPIsotropic(material.Name, isotropic.YoungsModulus, isotropic.PoissonsRatio, isotropic.ThermalExpansionCoeff) == 0; + success &= m_model.PropMaterial.SetMPIsotropic(material.DescriptionOrName(), isotropic.YoungsModulus, isotropic.PoissonsRatio, isotropic.ThermalExpansionCoeff) == 0; } else if (material is IOrthotropic) { @@ -72,12 +72,12 @@ private bool CreateObject(IMaterialFragment material) double[] v = orthoTropic.PoissonsRatio.ToDoubleArray(); double[] a = orthoTropic.ThermalExpansionCoeff.ToDoubleArray(); double[] g = orthoTropic.ShearModulus.ToDoubleArray(); - success &= m_model.PropMaterial.SetMPOrthotropic(material.Name, ref e, ref v, ref a, ref g) == 0; + success &= m_model.PropMaterial.SetMPOrthotropic(material.DescriptionOrName(), ref e, ref v, ref a, ref g) == 0; } - success &= m_model.PropMaterial.SetWeightAndMass(material.Name, 2, material.Density) == 0; + success &= m_model.PropMaterial.SetWeightAndMass(material.DescriptionOrName(), 2, material.Density) == 0; } if (!success) - Engine.Reflection.Compute.RecordWarning($"Failed to assign material: {material.Name}, ETABS may have overwritten some properties with default values"); + Engine.Reflection.Compute.RecordWarning($"Failed to assign material: {material.DescriptionOrName()}, ETABS may have overwritten some properties with default values"); return success; } diff --git a/Etabs_Adapter/CRUD/Create/Panel.cs b/Etabs_Adapter/CRUD/Create/Panel.cs index 8ebcde1e..3025d892 100644 --- a/Etabs_Adapter/CRUD/Create/Panel.cs +++ b/Etabs_Adapter/CRUD/Create/Panel.cs @@ -129,44 +129,35 @@ private bool CreateObject(ISurfaceProperty property2d) bool success = true; int retA = 0; - string propertyName = "None"; - if (property2d.Name != "") - { - property2d.CustomData[AdapterIdName] = propertyName = property2d.Name; - } - else - { - BH.Engine.Reflection.Compute.RecordWarning("Surface properties with no name will be converted to the null property 'None'."); - property2d.CustomData[AdapterIdName] = "None"; - return true; - } + string propertyName = property2d.DescriptionOrName(); + property2d.CustomData[AdapterIdName] = propertyName; eShellType shellType = ShellTypeToCSI(property2d); if (property2d.GetType() == typeof(Waffle)) { Waffle waffleProperty = (Waffle)property2d; - m_model.PropArea.SetSlab(propertyName, eSlabType.Waffle, shellType, property2d.Material.Name, waffleProperty.Thickness); + m_model.PropArea.SetSlab(propertyName, eSlabType.Waffle, shellType, property2d.Material.DescriptionOrName(), waffleProperty.Thickness); retA = m_model.PropArea.SetSlabWaffle(propertyName, waffleProperty.TotalDepthX, waffleProperty.Thickness, waffleProperty.StemWidthX, waffleProperty.StemWidthX, waffleProperty.SpacingX, waffleProperty.SpacingY); } else if (property2d.GetType() == typeof(Ribbed)) { Ribbed ribbedProperty = (Ribbed)property2d; - m_model.PropArea.SetSlab(propertyName, eSlabType.Ribbed, shellType, property2d.Material.Name, ribbedProperty.Thickness); + m_model.PropArea.SetSlab(propertyName, eSlabType.Ribbed, shellType, property2d.Material.DescriptionOrName(), ribbedProperty.Thickness); retA = m_model.PropArea.SetSlabRibbed(propertyName, ribbedProperty.TotalDepth, ribbedProperty.Thickness, ribbedProperty.StemWidth, ribbedProperty.StemWidth, ribbedProperty.Spacing, (int)ribbedProperty.Direction); } else if (property2d.GetType() == typeof(LoadingPanelProperty)) { - retA = m_model.PropArea.SetSlab(propertyName, eSlabType.Slab, shellType, property2d.Material.Name, 0); + retA = m_model.PropArea.SetSlab(propertyName, eSlabType.Slab, shellType, property2d.Material.DescriptionOrName(), 0); } else if (property2d.GetType() == typeof(ConstantThickness)) { ConstantThickness constantThickness = (ConstantThickness)property2d; if (constantThickness.PanelType == PanelType.Wall) - retA = m_model.PropArea.SetWall(propertyName, eWallPropType.Specified, shellType, property2d.Material.Name, constantThickness.Thickness); + retA = m_model.PropArea.SetWall(propertyName, eWallPropType.Specified, shellType, property2d.Material.DescriptionOrName(), constantThickness.Thickness); else - retA = m_model.PropArea.SetSlab(propertyName, eSlabType.Slab, shellType, property2d.Material.Name, constantThickness.Thickness); + retA = m_model.PropArea.SetSlab(propertyName, eSlabType.Slab, shellType, property2d.Material.DescriptionOrName(), constantThickness.Thickness); } diff --git a/Etabs_Adapter/CRUD/Create/SectionProperty.cs b/Etabs_Adapter/CRUD/Create/SectionProperty.cs index 9ba7ac5b..75b7f1ef 100644 --- a/Etabs_Adapter/CRUD/Create/SectionProperty.cs +++ b/Etabs_Adapter/CRUD/Create/SectionProperty.cs @@ -63,18 +63,9 @@ public partial class ETABS2016Adapter : BHoMAdapter private bool CreateObject(ISectionProperty bhSection) { - string propertyName = "None"; - if (bhSection.Name != "") - { - bhSection.CustomData[AdapterIdName] = propertyName = bhSection.Name; - } - else - { - BH.Engine.Reflection.Compute.RecordWarning("Section properties with no name will be converted to the null property 'None'."); - bhSection.CustomData[AdapterIdName] = "None"; - return true; - } - + string propertyName = bhSection.DescriptionOrName(); + bhSection.CustomData[AdapterIdName] = propertyName; + if (!LoadFromDatabase(bhSection)) { SetSection(bhSection as dynamic); @@ -95,7 +86,7 @@ private bool CreateObject(ISectionProperty bhSection) etabsMods[6] = 1; //Mass, not currently implemented etabsMods[7] = 1; //Weight, not currently implemented - m_model.PropFrame.SetModifiers(bhSection.Name, ref etabsMods); + m_model.PropFrame.SetModifiers(propertyName, ref etabsMods); } return true; @@ -107,14 +98,14 @@ private bool CreateObject(ISectionProperty bhSection) private void SetSection(IGeometricalSection section) { - ISetProfile(section.SectionProfile, section.Name, section.Material); + ISetProfile(section.SectionProfile, section.DescriptionOrName(), section.Material); } /***************************************************/ private void SetSection(ExplicitSection section) { - m_model.PropFrame.SetGeneral(section.Name, section.Material.Name, section.Vz + section.Vpz, section.Vy + section.Vpy, + m_model.PropFrame.SetGeneral(section.DescriptionOrName(), section.Material.DescriptionOrName(), section.Vz + section.Vpz, section.Vy + section.Vpy, section.Area, section.Asz, section.Asy, section.J, section.Iz, section.Iy, // I22, I33 section.Welz, section.Wely, // S22, S33 @@ -126,7 +117,7 @@ private void SetSection(ExplicitSection section) private void SetSection(ISectionProperty section) { - CreateElementError(section.GetType().ToString(), section.Name); + CreateElementError(section.GetType().ToString(), section.DescriptionOrName()); } /***************************************************/ @@ -177,14 +168,14 @@ private void SetProfile(TaperedProfile profile, string sectionName, IMaterialFra private void SetProfile(TubeProfile profile, string sectionName, IMaterialFragment material) { - m_model.PropFrame.SetPipe(sectionName, material.Name, profile.Diameter, profile.Thickness); + m_model.PropFrame.SetPipe(sectionName, material.DescriptionOrName(), profile.Diameter, profile.Thickness); } /***************************************************/ private void SetProfile(BoxProfile profile, string sectionName, IMaterialFragment material) { - m_model.PropFrame.SetTube(sectionName, material.Name, profile.Height, profile.Width, profile.Thickness, profile.Thickness); + m_model.PropFrame.SetTube(sectionName, material.DescriptionOrName(), profile.Height, profile.Width, profile.Thickness, profile.Thickness); } /***************************************************/ @@ -193,28 +184,28 @@ private void SetProfile(FabricatedBoxProfile profile, string sectionName, IMater { if (profile.TopFlangeThickness != profile.BotFlangeThickness) Engine.Reflection.Compute.RecordWarning("different thickness of top and bottom flange is not supported in ETABS"); - m_model.PropFrame.SetTube(sectionName, material.Name, profile.Height, profile.Width, profile.TopFlangeThickness, profile.WebThickness); + m_model.PropFrame.SetTube(sectionName, material.DescriptionOrName(), profile.Height, profile.Width, profile.TopFlangeThickness, profile.WebThickness); } /***************************************************/ private void SetProfile(ISectionProfile profile, string sectionName, IMaterialFragment material) { - m_model.PropFrame.SetISection(sectionName, material.Name, profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness, profile.Width, profile.FlangeThickness); + m_model.PropFrame.SetISection(sectionName, material.DescriptionOrName(), profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness, profile.Width, profile.FlangeThickness); } /***************************************************/ private void SetProfile(FabricatedISectionProfile profile, string sectionName, IMaterialFragment material) { - m_model.PropFrame.SetISection(sectionName, material.Name, profile.Height, profile.TopFlangeWidth, profile.TopFlangeThickness, profile.WebThickness, profile.BotFlangeWidth, profile.BotFlangeThickness); + m_model.PropFrame.SetISection(sectionName, material.DescriptionOrName(), profile.Height, profile.TopFlangeWidth, profile.TopFlangeThickness, profile.WebThickness, profile.BotFlangeWidth, profile.BotFlangeThickness); } /***************************************************/ private void SetProfile(ChannelProfile profile, string sectionName, IMaterialFragment material) { - m_model.PropFrame.SetChannel(sectionName, material.Name, profile.Height, profile.FlangeWidth, profile.FlangeThickness, profile.WebThickness); + m_model.PropFrame.SetChannel(sectionName, material.DescriptionOrName(), profile.Height, profile.FlangeWidth, profile.FlangeThickness, profile.WebThickness); if (profile.MirrorAboutLocalZ) RecordFlippingError(sectionName); } @@ -225,12 +216,12 @@ private void SetProfile(AngleProfile profile, string sectionName, IMaterialFragm { if (material is Steel || material is Aluminium) - m_model.PropFrame.SetSteelAngle(sectionName, material.Name, profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness, profile.RootRadius, profile.MirrorAboutLocalZ, profile.MirrorAboutLocalY); + m_model.PropFrame.SetSteelAngle(sectionName, material.DescriptionOrName(), profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness, profile.RootRadius, profile.MirrorAboutLocalZ, profile.MirrorAboutLocalY); else if (material is Concrete) - m_model.PropFrame.SetConcreteL(sectionName, material.Name, profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness, profile.WebThickness, profile.MirrorAboutLocalZ, profile.MirrorAboutLocalY); + m_model.PropFrame.SetConcreteL(sectionName, material.DescriptionOrName(), profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness, profile.WebThickness, profile.MirrorAboutLocalZ, profile.MirrorAboutLocalY); else { - m_model.PropFrame.SetAngle(sectionName, material.Name, profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness); + m_model.PropFrame.SetAngle(sectionName, material.DescriptionOrName(), profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness); if (profile.MirrorAboutLocalY || profile.MirrorAboutLocalZ) RecordFlippingError(sectionName); } @@ -242,12 +233,12 @@ private void SetProfile(AngleProfile profile, string sectionName, IMaterialFragm private void SetProfile(TSectionProfile profile, string sectionName, IMaterialFragment material) { if (material is Steel || material is Aluminium) - m_model.PropFrame.SetSteelTee(sectionName, material.Name, profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness, profile.RootRadius, profile.MirrorAboutLocalY); + m_model.PropFrame.SetSteelTee(sectionName, material.DescriptionOrName(), profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness, profile.RootRadius, profile.MirrorAboutLocalY); else if (material is Concrete) - m_model.PropFrame.SetConcreteTee(sectionName, material.Name, profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness, profile.WebThickness, profile.MirrorAboutLocalY); + m_model.PropFrame.SetConcreteTee(sectionName, material.DescriptionOrName(), profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness, profile.WebThickness, profile.MirrorAboutLocalY); else { - m_model.PropFrame.SetTee(sectionName, material.Name, profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness); + m_model.PropFrame.SetTee(sectionName, material.DescriptionOrName(), profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness); if (profile.MirrorAboutLocalY) RecordFlippingError(sectionName); } @@ -258,14 +249,14 @@ private void SetProfile(TSectionProfile profile, string sectionName, IMaterialFr private void SetProfile(RectangleProfile profile, string sectionName, IMaterialFragment material) { - m_model.PropFrame.SetRectangle(sectionName, material.Name, profile.Height, profile.Width); + m_model.PropFrame.SetRectangle(sectionName, material.DescriptionOrName(), profile.Height, profile.Width); } /***************************************************/ private void SetProfile(CircleProfile profile, string sectionName, IMaterialFragment material) { - m_model.PropFrame.SetCircle(sectionName, material.Name, profile.Diameter); + m_model.PropFrame.SetCircle(sectionName, material.DescriptionOrName(), profile.Diameter); } /***************************************************/ @@ -283,7 +274,7 @@ private bool LoadFromDatabase(ISectionProperty bhSection) if (EtabsSettings.DatabaseSettings.SectionDatabase == SectionDatabase.None) return false; - string bhName = bhSection.Name; + string bhName = bhSection.DescriptionOrName(); // Formatt as uppercase and no spaces bhName = bhName.ToUpper(); @@ -314,8 +305,8 @@ private bool LoadFromDatabase(ISectionProperty bhSection) // Try to get it from the database, return false on faliure if (1 == m_model.PropFrame.ImportProp( - bhSection.Name, - bhSection.Material.Name, + bhSection.DescriptionOrName(), + bhSection.Material.DescriptionOrName(), ToEtabsFileName(EtabsSettings.DatabaseSettings.SectionDatabase), m_DBSectionsNames[index])) { @@ -323,7 +314,7 @@ private bool LoadFromDatabase(ISectionProperty bhSection) } // Notify user and return true to stop the adapter from creating a new Section - Engine.Reflection.Compute.RecordNote(bhSection.Name + " properties has been assigned from the database section " + bhName + "."); + Engine.Reflection.Compute.RecordNote(bhSection.DescriptionOrName() + " properties has been assigned from the database section " + bhName + "."); return true; } diff --git a/Etabs_Adapter/CRUD/Read/SectionProperty.cs b/Etabs_Adapter/CRUD/Read/SectionProperty.cs index e1c0164a..5e4f4add 100644 --- a/Etabs_Adapter/CRUD/Read/SectionProperty.cs +++ b/Etabs_Adapter/CRUD/Read/SectionProperty.cs @@ -35,6 +35,7 @@ using BH.oM.Geometry.ShapeProfiles; using BH.oM.Adapters.ETABS.Fragments; using BH.oM.Adapters.ETABS; +using BH.Engine.Structure; #if Debug17 || Release17 using ETABSv17; #elif Debug18 || Release18 @@ -58,7 +59,7 @@ public partial class ETABS2016Adapter : BHoMAdapter private List ReadSectionProperty(List ids = null) { List propList = new List(); - Dictionary bhomMaterials = ReadMaterial().ToDictionary(x => x.Name); + Dictionary bhomMaterials = ReadMaterial().ToDictionary(x => x.DescriptionOrName()); int nameCount = 0; string[] names = { }; @@ -193,7 +194,7 @@ private List ReadSectionProperty(List ids = null) // Getting a Profile from a name in the propList Func getProfile = sectionName => { - ISectionProperty sec = propList.First(x => x.Name == sectionName); + ISectionProperty sec = propList.First(x => x.DescriptionOrName() == sectionName); if (sec is IGeometricalSection) return (sec as IGeometricalSection).SectionProfile; else @@ -218,10 +219,10 @@ private List ReadSectionProperty(List ids = null) // Find the material of all elements and create a singel one (or have warning) foreach (string subSectionName in startSec.Concat(endSec)) { - ISectionProperty sec = propList.First(x => x.Name == subSectionName); + ISectionProperty sec = propList.First(x => x.DescriptionOrName() == subSectionName); if (materialName == "") - materialName = sec.Material.Name; - else if (materialName != sec.Material.Name) + materialName = sec.Material.DescriptionOrName(); + else if (materialName != sec.Material.DescriptionOrName()) { materialName = ""; Engine.Reflection.Compute.RecordWarning("All sub-sections must have the same material."); diff --git a/Etabs_Adapter/Types/Comparer.cs b/Etabs_Adapter/Types/Comparer.cs index 940885ee..adff006b 100644 --- a/Etabs_Adapter/Types/Comparer.cs +++ b/Etabs_Adapter/Types/Comparer.cs @@ -31,6 +31,7 @@ using BH.oM.Structure.SurfaceProperties; using BH.oM.Structure.MaterialFragments; using BH.Engine.Base.Objects; +using BH.Engine.Structure; namespace BH.Adapter.ETABS { @@ -53,9 +54,9 @@ protected void SetupComparers() { {typeof(Node), new BH.Engine.Structure.NodeDistanceComparer(3) }, {typeof(Bar), new BH.Engine.Structure.BarEndNodesDistanceComparer(3) }, - {typeof(ISectionProperty), new BHoMObjectNameOrToStringComparer() }, - {typeof(IMaterialFragment), new BHoMObjectNameComparer() }, - {typeof(ISurfaceProperty), new BHoMObjectNameComparer() }, + {typeof(ISectionProperty), new NameOrDescriptionComparer() }, + {typeof(IMaterialFragment), new NameOrDescriptionComparer() }, + {typeof(ISurfaceProperty), new NameOrDescriptionComparer() }, {typeof(BH.oM.Adapters.ETABS.Elements.Diaphragm), new BHoMObjectNameComparer() }, }; }