Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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: 1 addition & 0 deletions ETABS_oM/ETABS_oM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Elements\Tower.cs" />
<Compile Include="Enums\EtabsVersion.cs" />
<Compile Include="Fragments\ETABSId.cs" />
<Compile Include="Fragments\ShellTypeFragment.cs" />
Expand Down
51 changes: 51 additions & 0 deletions ETABS_oM/Elements/Tower.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2025, 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 BH.oM.Base;
using BH.oM.Structure.Elements;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BH.oM.Adapters.ETABS.Elements
{
public class Tower : BHoMObject, IFragment
{
/***************************************************/
/**** Public Properties ****/
/***************************************************/

[Description("Name of the Tower the element belongs to.")]
public virtual string Name { get; set; }

/***************************************************/
}
}






82 changes: 67 additions & 15 deletions Etabs_Adapter/CRUD/Read/Level.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
using System.Threading.Tasks;
using BH.oM.Spatial.SettingOut;
using BH.Engine.Adapters.ETABS;
using BH.oM.Base;


namespace BH.Adapter.ETABS
Expand All @@ -47,28 +48,79 @@ public partial class ETABSAdapter : BHoMAdapter
private List<Level> ReadLevel(List<string> ids = null)
{
List<Level> levellist = new List<Level>();
int numberNames = 0;
string[] names = null;
m_model.Story.GetNameList(ref numberNames, ref names);

ids = FilterIds(ids, names);
int towersNum = 0;
string[] towerNames = null;
m_model.Tower.GetNameList(ref towersNum, ref towerNames);

foreach (string id in ids)
// Prepare variables
string tableKey = "Tower and Base Story Definitions";
string[] fieldKeyList = null;
string groupName = "All";
int tableVersion = 0;
string[] fieldsKeysIncluded = null;
int numberRecords = 0;
string[] tableData = null;

// Get table data
m_model.DatabaseTables.GetTableForDisplayArray(tableKey, ref fieldKeyList, groupName, ref tableVersion,
ref fieldsKeysIncluded, ref numberRecords, ref tableData);


double baseElevation = 0;
int numberStories = 0;
bool[] isMasterStory = null;
bool[] spliceAbove = null;
double[] storyElevations = null;
double[] storyHeights = null;
double[] spliceHeight = null;
string[] storyNames = null;
string[] similarToStory = null;
int[] color = null;

List<string> storyNamesList;
List<double> storyElevationsList;


for (int i = 0; i < towersNum; i++)
{
ETABSId etabsid = new ETABSId();
etabsid.Id = id;

double elevation = 0;
int ret = m_model.Story.GetElevation(id, ref elevation);
m_model.Tower.SetActiveTower(towerNames[i]);

m_model.Story.GetStories_2(ref baseElevation, ref numberStories, ref storyNames, ref storyElevations, ref storyHeights,
ref isMasterStory, ref similarToStory, ref spliceAbove, ref spliceHeight, ref color);

int i_baseLevelName = fieldsKeysIncluded.ToList().IndexOf("BSName")+i*fieldsKeysIncluded.Count();
int i_baseLevelElev = fieldsKeysIncluded.ToList().IndexOf("BSElev")+i*fieldsKeysIncluded.Count();
string baseLevelName = tableData[i_baseLevelName];
double baseLevelElev = Double.Parse(tableData[i_baseLevelElev]);

storyNamesList = storyNames.ToList();
storyNamesList.Insert(0, baseLevelName);
storyNames = storyNamesList.ToArray();

storyElevationsList = storyElevations.ToList();
storyElevationsList.Insert(0, baseLevelElev);
storyElevations = storyElevationsList.ToArray();

ids = FilterIds(ids, storyNames);

for (int j = 0; j < ids.Count; j++)
{
ETABSId etabsid = new ETABSId();
etabsid.Id = ids[j];

string guid = null;
m_model.Story.GetGUID(ids[j], ref guid);
etabsid.PersistentId = guid;

string guid = null;
m_model.Story.GetGUID(id, ref guid);
etabsid.PersistentId = guid;
Level lvl = new Level() { Elevation = storyElevations[j], Name = ids[j] };
lvl.Fragments.Add( new BH.oM.Adapters.ETABS.Elements.Tower { Name = towerNames[i] } );

Level lvl = new Level() { Elevation = elevation, Name = id };
lvl.SetAdapterId(etabsid);
levellist.Add(lvl);
}

lvl.SetAdapterId(etabsid);
levellist.Add(lvl);
}

return levellist;
Expand Down
Loading