Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read ETABS Database sections #281

Merged
merged 19 commits into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ETABS_Engine/ETABS_Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
<Compile Include="Convert\ToBHoM.cs" />
<Compile Include="Convert\ToCSI.cs" />
<Compile Include="Create\Diaphragm.cs" />
<Compile Include="Create\EtabsConfig.cs" />
<Compile Include="Create\MassSource.cs" />
<Compile Include="Create\Pier.cs" />
<Compile Include="Create\Spandrel.cs" />
Expand Down
4 changes: 3 additions & 1 deletion ETABS_oM/ETABS_oM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Config\EtabsConfig.cs" />
<Compile Include="Settings\DataBaseSettings.cs" />
<Compile Include="Settings\EtabsSettings.cs" />
<Compile Include="Enums\SectionDatabase.cs" />
<Compile Include="Fragments\AutoLengthOffset.cs" />
<Compile Include="Elements\Diaphragm.cs" />
<Compile Include="Elements\Pier.cs" />
Expand Down
65 changes: 65 additions & 0 deletions ETABS_oM/Enums/SectionDatabase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2020, 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 <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BH.oM.Adapters.ETABS
{
[Description("The ETABS defined section databases to read sections from if the name of the sections you push share a name with one avalible in the database")]
public enum SectionDatabase
{
kThorsager marked this conversation as resolved.
Show resolved Hide resolved
None = 0,
AISC14 = 1,
AISC14M = 2,
AISC15 = 3,
AISC15M = 4,
ArcelorMittal_British = 5,
ArcelorMittal_BritishHISTAR = 6,
ArcelorMittal_Europe = 7,
ArcelorMittal_EuropeHISTAR = 8,
ArcelorMittal_Japan = 9,
ArcelorMittal_Russia = 10,
ArcelorMittal_US_ASTM_A913 = 11,
ArcelorMittal_US_ASTM_A913M = 12,
ArcelorMittal_US_ASTM_A992 = 13,
ArcelorMittal_US_ASTM_A992M = 14,
Australia_NewZealand = 15,
BSShapes2006 = 16,
ChineseGB08 = 17,
CISC9 = 18,
CISC10 = 19,
CoreBraceBRB_2016 = 20,
Euro = 21,
Indian = 22,
JIS_G_3192_2014 = 23,
Nordic = 24,
Russian = 25,
SJIJoists = 26,
StarSeismicBRB = 27
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,20 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BH.oM.Adapters.ETABS;
using BH.oM.Base;
using BH.oM.Reflection.Attributes;
using System.ComponentModel;


namespace BH.Engine.ETABS
namespace BH.oM.Adapters.ETABS
{
public static partial class Create
public class DatabaseSettings : IObject
{
/***************************************************/
/**** Public Methods ****/
/**** Public Properties ****/
/***************************************************/

public static EtabsConfig EtabsConfig(bool replaceLoads = false)
{
return new EtabsConfig
{
ReplaceLoads = replaceLoads
};
}
[Description("The ETABS defined section database to read sections from if the name of the sections you push share a name with one avalible in the database")]
public SectionDatabase SectionDatabase { get; set; } = SectionDatabase.None;

/***************************************************/
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

namespace BH.oM.Adapters.ETABS
{
public class EtabsConfig : BHoMObject
public class EtabsSettings : IObject
{
/***************************************************/
/**** Public Properties ****/
Expand All @@ -40,6 +40,9 @@ public class EtabsConfig : BHoMObject
[Description("Sets whether the loads being pushed should overwrite existing loads on the same object within the same loadcase")]
public bool ReplaceLoads { get; set; } = false;

[Description("")]
public DatabaseSettings DatabaseSettings { get; set; } = new DatabaseSettings();

/***************************************************/
}
}
Expand Down
2 changes: 1 addition & 1 deletion Etabs_Adapter/CRUD/Create/Load.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public partial class ETABS2016Adapter : BHoMAdapter

private bool CreateObject(ILoad bhLoad)
{
SetLoad(bhLoad as dynamic, this.EtabsConfig.ReplaceLoads);
SetLoad(bhLoad as dynamic, this.EtabsSettings.ReplaceLoads);

return true;
}
Expand Down
174 changes: 173 additions & 1 deletion Etabs_Adapter/CRUD/Create/SectionProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ private bool CreateObject(ISectionProperty bhSection)
return true;
}

SetSection(bhSection as dynamic);
if (!LoadFromDatabase(bhSection))
{
SetSection(bhSection as dynamic);
}

double[] modifiers = bhSection.Modifiers();

Expand Down Expand Up @@ -238,5 +241,174 @@ private void SetProfile(IProfile profile, string sectionName, IMaterialFragment
}

/***************************************************/


private bool LoadFromDatabase(ISectionProperty bhSection)
{
if (EtabsSettings.DatabaseSettings.SectionDatabase == SectionDatabase.None)
return false;

string bhName = bhSection.Name;

// Formatt as uppercase and no spaces
bhName = bhName.ToUpper();
bhName = bhName.Replace(" ", "");

// remove trailing zeros
string[] sub = bhName.Split('X');

for (int i = 0; i < sub.Length; i++)
{
if (sub[i].EndsWith(".0"))
sub[i] = string.Join("", sub[i].Take(sub[i].Length - 2).ToArray());
}

bhName = string.Join("X", sub);

// Get char up intill first number
string startOfName = string.Concat(bhName.TakeWhile(c => c < '0' || c > '9'));
// look in dictionary if there's any discrepencies between etabs and BHoMs naming conventions (if so, replace)
string replace;
if (BHoMToEtabsNamingConventions(EtabsSettings.DatabaseSettings.SectionDatabase).TryGetValue(startOfName, out replace))
bhName = bhName.Replace(startOfName, replace);

// Look through a uppercase formatted list of avalible sectionnames, and return the index of the one who matches bhName
int index = m_DBSectionsNames.Select(x => x.ToUpper().Replace(" ", "")).ToList().IndexOf(bhName);
if (index == -1)
return false;

// Try to get it from the database, return false on faliure
if (1 == m_model.PropFrame.ImportProp(
bhSection.Name,
bhSection.Material.Name,
ToEtabsFileName(EtabsSettings.DatabaseSettings.SectionDatabase),
m_DBSectionsNames[index]))
{
return false;
}

// 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 + ".");
return true;
}

/***************************************************/

private Dictionary<string, string> BHoMToEtabsNamingConventions(SectionDatabase sectionDatabase)
{
switch (sectionDatabase)
{
case SectionDatabase.BSShapes2006:
return new Dictionary<string, string>()
{
{ "UB", "UKB" },
{ "UC", "UKC" },
{ "UBP", "UKBP" },
{ "L", "UKA" },
{ "PFC", "UKPFC" },
{ "CHS", "CHHF" },
{ "RHS", "RHHF" },
{ "SHS", "SHHF" },
{ "TUB", "UKT" },
{ "TUC", "UKT" }
};
case SectionDatabase.None:
case SectionDatabase.AISC14:
case SectionDatabase.AISC14M:
case SectionDatabase.AISC15:
case SectionDatabase.AISC15M:
case SectionDatabase.ArcelorMittal_British:
case SectionDatabase.ArcelorMittal_BritishHISTAR:
case SectionDatabase.ArcelorMittal_Europe:
case SectionDatabase.ArcelorMittal_EuropeHISTAR:
case SectionDatabase.ArcelorMittal_Japan:
case SectionDatabase.ArcelorMittal_Russia:
case SectionDatabase.ArcelorMittal_US_ASTM_A913:
case SectionDatabase.ArcelorMittal_US_ASTM_A913M:
case SectionDatabase.ArcelorMittal_US_ASTM_A992:
case SectionDatabase.ArcelorMittal_US_ASTM_A992M:
case SectionDatabase.Australia_NewZealand:
case SectionDatabase.ChineseGB08:
case SectionDatabase.CISC9:
case SectionDatabase.CISC10:
case SectionDatabase.CoreBraceBRB_2016:
case SectionDatabase.Euro:
case SectionDatabase.Indian:
case SectionDatabase.JIS_G_3192_2014:
case SectionDatabase.Nordic:
case SectionDatabase.Russian:
case SectionDatabase.SJIJoists:
case SectionDatabase.StarSeismicBRB:
default:
return new Dictionary<string, string>();
}
}

/***************************************************/

private string ToEtabsFileName(SectionDatabase sectionDB)
{
switch (sectionDB)
{
case SectionDatabase.AISC14:
return "AISC14.xml";
case SectionDatabase.AISC14M:
return "AISC14.xml";
case SectionDatabase.AISC15:
return "AISC15.xml";
case SectionDatabase.AISC15M:
return "AISC15M.xml";
case SectionDatabase.ArcelorMittal_British:
return "ArcelorMittal_British.xml";
case SectionDatabase.ArcelorMittal_BritishHISTAR:
return "ArcelorMittal_BritishHISTAR.xml";
case SectionDatabase.ArcelorMittal_Europe:
return "ArcelorMittal_Europe.xml";
case SectionDatabase.ArcelorMittal_EuropeHISTAR:
return "ArcelorMittal_EuropeHISTAR.xml";
case SectionDatabase.ArcelorMittal_Japan:
return "ArcelorMittal_Japan.xml";
case SectionDatabase.ArcelorMittal_Russia:
return "ArcelorMittal_Russia.xml";
case SectionDatabase.ArcelorMittal_US_ASTM_A913:
return "ArcelorMittal_US_ASTM-A913.xml";
case SectionDatabase.ArcelorMittal_US_ASTM_A913M:
return "ArcelorMittal_US_ASTM-A913M.xml";
case SectionDatabase.ArcelorMittal_US_ASTM_A992:
return "ArcelorMittal_US_ASTM-A992.xml";
case SectionDatabase.ArcelorMittal_US_ASTM_A992M:
return "ArcelorMittal_US_ASTM-A992M.xml";
case SectionDatabase.Australia_NewZealand:
return "Australia-NewZealand.xml";
case SectionDatabase.BSShapes2006:
return "BSShapes2006.xml";
case SectionDatabase.ChineseGB08:
return "ChineseGB08.xml";
case SectionDatabase.CISC9:
return "CISC9.xml";
case SectionDatabase.CISC10:
return "CISC10.xml";
case SectionDatabase.CoreBraceBRB_2016:
return "CoreBraceBRB_2016.xml";
case SectionDatabase.Euro:
return "Euro.xml";
case SectionDatabase.Indian:
return "Indian.xml";
case SectionDatabase.JIS_G_3192_2014:
return "JIS-G-3192-2014.xml";
case SectionDatabase.Nordic:
return "Nordic.xml";
case SectionDatabase.Russian:
return "Russian.xml";
case SectionDatabase.SJIJoists:
return "SJIJoists.xml";
case SectionDatabase.StarSeismicBRB:
return "StarSeismicBRB.xml";
default:
return "";
}
}

/***************************************************/
}
}
1 change: 1 addition & 0 deletions Etabs_Adapter/CRUD/Read/SectionProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
using BH.oM.Geometry;
using BH.oM.Geometry.ShapeProfiles;
using BH.oM.Adapters.ETABS.Fragments;
using BH.oM.Adapters.ETABS;
#if Debug17 || Release17
using ETABSv17;
#elif Debug18 || Release18
Expand Down
Loading