Skip to content
Open
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
2 changes: 1 addition & 1 deletion ETABS_Engine/ETABS_Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Product>ETABS_Engine</Product>
<Copyright>Copyright � https://github.com/BHoM</Copyright>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<FileVersion>9.1.0.0</FileVersion>
<FileVersion>9.2.0.0</FileVersion>
</PropertyGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="xcopy &quot;$(TargetDir)$(TargetFileName)&quot; &quot;C:\ProgramData\BHoM\Assemblies&quot; /Y" />
Expand Down
2 changes: 1 addition & 1 deletion ETABS_oM/ETABS_oM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Product>ETABS_oM</Product>
<Copyright>Copyright � https://github.com/BHoM</Copyright>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<FileVersion>9.1.0.0</FileVersion>
<FileVersion>9.2.0.0</FileVersion>
</PropertyGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="xcopy &quot;$(TargetDir)$(TargetFileName)&quot; &quot;C:\ProgramData\BHoM\Assemblies&quot; /Y" />
Expand Down
11 changes: 8 additions & 3 deletions Etabs_Adapter/CRUD/Create/Bar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,20 @@ private bool CreateObject(Bar bhBar)
string story = "";
string guid = null;

ETABSId etabsIdFragment = new ETABSId { Id = name };
// Assign the Unique Name to the ETABS Element
string newName = SetUniqueName(bhBar, name);

if (m_model.FrameObj.GetLabelFromName(name, ref label, ref story) == 0)
if (newName == null) return false;

ETABSId etabsIdFragment = new ETABSId { Id = newName };

if (m_model.FrameObj.GetLabelFromName(newName, ref label, ref story) == 0)
{
etabsIdFragment.Label = label;
etabsIdFragment.Story = story;
}

if (m_model.AreaObj.GetGUID(name, ref guid) == 0)
if (m_model.FrameObj.GetGUID(newName, ref guid) == 0)
etabsIdFragment.PersistentId = guid;

bhBar.SetAdapterId(etabsIdFragment);
Expand Down
50 changes: 48 additions & 2 deletions Etabs_Adapter/CRUD/Create/Link.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
using BH.Engine.Adapters.ETABS;
using BH.Engine.Structure;
using BH.oM.Adapters.ETABS;
using BH.oM.Analytical.Elements;
using BH.oM.Structure.Constraints;
using BH.oM.Structure.Elements;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Xml.Linq;


namespace BH.Adapter.ETABS
Expand Down Expand Up @@ -68,7 +70,12 @@ private bool CreateObject(RigidLink bhLink)
linkIds.Add(name);
}

multiId.Id = linkIds;
// Assign the Unique Name to the ETABS Element
List<string> newLinkNames = SetUniqueName(bhLink, linkIds);

if (newLinkNames == null) return false;

multiId.Id = newLinkNames;
bhLink.SetAdapterId(multiId);

SetGroup(bhLink);
Expand Down Expand Up @@ -110,6 +117,45 @@ private bool CreateObject(LinkConstraint bhLinkConstraint)

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

[Description("Concatenates the last 7 characters of the ETABS Element GUID and the Link Name to get the Unique Name to assign to the ETABS Element.")]
private List<string> SetUniqueName(RigidLink bhLink, List<string> names)
{

int ret01, ret02;
string guid = null;
string tempLinkName = "";
List<string> newLinkNames = new List<string>();

foreach (string name in names) {

/* 1. GET THE ETABS ELEMENT GUID */
tempLinkName = "";
ret01 = m_model.LinkObj.GetGUID(name, ref guid);

/* 2. CREATE THE NEW UNIQUE NAME */
if (bhLink.Name == "")
{
tempLinkName = guid.Substring(guid.Length - 7);
}
else
{
tempLinkName = guid.Substring(guid.Length - 7) + "::" + bhLink.Name;
}

/* 3. ASSIGN THE NEW UNIQUE NAME TO THE ETABS ELEMENT */
ret02 = m_model.LinkObj.ChangeName(name, tempLinkName);

/* 4. ADD THE NEW NAME TO THE LIST */
newLinkNames.Add(tempLinkName);

if (!(ret01 == 0 && ret02 == 0)) return null;

}

return newLinkNames;
}

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

Expand Down
16 changes: 12 additions & 4 deletions Etabs_Adapter/CRUD/Create/Node.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
using BH.Engine.Geometry;
using BH.Engine.Structure;
using BH.oM.Adapters.ETABS;
using BH.oM.Analytical.Elements;
using BH.oM.Geometry;
using BH.oM.Structure.Elements;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;

namespace BH.Adapter.ETABS
Expand All @@ -53,23 +55,29 @@ private bool CreateObject(Node bhNode)
oM.Geometry.Point position = bhNode.Position;
if (m_model.PointObj.AddCartesian(position.X, position.Y, position.Z, ref name) == 0)
{
etabsid.Id = name;

// Assign the Unique Name to the ETABS Element
string newName = SetUniqueName(bhNode, name);

if (newName == null) return false;

etabsid.Id = newName;

//Label and story
string label = "";
string story = "";
if (m_model.PointObj.GetLabelFromName(name, ref label, ref story) == 0)
if (m_model.PointObj.GetLabelFromName(newName, ref label, ref story) == 0)
{
etabsid.Label = label;
etabsid.Story = story;
}

string guid = null;
if (m_model.PointObj.GetGUID(name, ref guid) == 0)
if (m_model.PointObj.GetGUID(newName, ref guid) == 0)
etabsid.PersistentId = guid;

bhNode.SetAdapterId(etabsid);
SetObject(bhNode, name);
SetObject(bhNode, newName);
SetGroup(bhNode);
}

Expand Down
18 changes: 13 additions & 5 deletions Etabs_Adapter/CRUD/Create/Opening.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@
using BH.oM.Adapters.ETABS;
using BH.oM.Adapters.ETABS.Elements;
using BH.oM.Analytical.Elements;
using BH.oM.Data.Collections;
using BH.oM.Geometry;
using BH.oM.Structure.Elements;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Xml.Linq;


namespace BH.Adapter.ETABS
Expand Down Expand Up @@ -85,26 +87,32 @@ private bool CreateObject(Opening bhOpening)

string openingName = GetAdapterId<string>(bhOpening);
retA = m_model.AreaObj.AddByCoord(segmentCount, ref x, ref y, ref z, ref openingName, "Default");

// Assign the Unique Name to the ETABS Element
string newName = SetUniqueName(bhOpening, openingName);

if (newName == null) return false;

ETABSId etabsid = new ETABSId();
etabsid.Id = openingName;
etabsid.Id = newName;

//Label and story
string label = "";
string story = "";
string guid = null;

if (m_model.AreaObj.GetLabelFromName(openingName, ref label, ref story) == 0)
if (m_model.AreaObj.GetLabelFromName(newName, ref label, ref story) == 0)
{
etabsid.Label = label;
etabsid.Story = story;
}

if (m_model.AreaObj.GetGUID(openingName, ref guid) == 0)
if (m_model.AreaObj.GetGUID(newName, ref guid) == 0)
etabsid.PersistentId = guid;

bhOpening.SetAdapterId(etabsid);

m_model.AreaObj.SetOpening(openingName, true);
m_model.AreaObj.SetOpening(newName, true);

//Set Groups Assignment
SetGroup(bhOpening);
Expand Down
24 changes: 16 additions & 8 deletions Etabs_Adapter/CRUD/Create/Panel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
using BH.oM.Structure.Elements;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;


Expand Down Expand Up @@ -89,21 +90,27 @@ private bool CreateObject(Panel bhPanel)
}

retA = m_model.AreaObj.AddByCoord(segmentCount, ref x, ref y, ref z, ref name, propertyName);

// Assign the Unique Name to the ETABS Element
string newName = SetUniqueName(bhPanel, name);

if (newName == null) return false;

ETABSId etabsid = new ETABSId();
etabsid.Id = name;
etabsid.Id = newName;

//Label and story
string label = "";
string story = "";
string guid = null;

if (m_model.AreaObj.GetLabelFromName(name, ref label, ref story) == 0)
if (m_model.AreaObj.GetLabelFromName(newName, ref label, ref story) == 0)
{
etabsid.Label = label;
etabsid.Story = story;
}

if (m_model.AreaObj.GetGUID(name, ref guid) == 0)
if (m_model.AreaObj.GetGUID(newName, ref guid) == 0)
etabsid.PersistentId = guid;

bhPanel.SetAdapterId(etabsid);
Expand Down Expand Up @@ -146,7 +153,7 @@ private bool CreateObject(Panel bhPanel)
z[j] = boundaryPoints[j].Z;
}

string openingName = name + "_Opening_" + i;
string openingName = bhPanel.Name + "_Opening_" + i;
m_model.AreaObj.AddByCoord(segmentCount, ref x, ref y, ref z, ref openingName, "");//<-- setting panel property to empty string, verify that this is correct
m_model.AreaObj.SetOpening(openingName, true);

Expand All @@ -156,7 +163,7 @@ private bool CreateObject(Panel bhPanel)

//Set local orientations:
Basis orientation = bhPanel.LocalOrientation();
m_model.AreaObj.SetLocalAxes(name, Convert.ToEtabsPanelOrientation(orientation.Z, orientation.Y));
m_model.AreaObj.SetLocalAxes(newName, Convert.ToEtabsPanelOrientation(orientation.Z, orientation.Y));

Pier pier = bhPanel.Pier();
Spandrel spandrel = bhPanel.Spandrel();
Expand All @@ -165,16 +172,16 @@ private bool CreateObject(Panel bhPanel)
if (pier != null)
{
int ret = m_model.PierLabel.SetPier(pier.Name);
ret = m_model.AreaObj.SetPier(name, pier.Name);
ret = m_model.AreaObj.SetPier(newName, pier.Name);
}
if (spandrel != null)
{
int ret = m_model.SpandrelLabel.SetSpandrel(spandrel.Name, false);
ret = m_model.AreaObj.SetSpandrel(name, spandrel.Name);
ret = m_model.AreaObj.SetSpandrel(newName, spandrel.Name);
}
if (diaphragm != null)
{
m_model.AreaObj.SetDiaphragm(name, diaphragm.Name);
m_model.AreaObj.SetDiaphragm(newName, diaphragm.Name);
}

//Set Groups Assignment
Expand Down Expand Up @@ -203,6 +210,7 @@ private static void NonLinearEdgesCheck(List<Edge> edges)

}


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

}
Expand Down
51 changes: 50 additions & 1 deletion Etabs_Adapter/CRUD/Create/_Create.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@

using BH.Engine.Adapters.ETABS;
using BH.oM.Adapter;
using BH.oM.Adapters.ETABS;
using BH.oM.Adapters.ETABS.Elements;
using BH.oM.Base;
using BH.oM.Structure.Elements;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using BH.oM.Adapters.ETABS;
using BH.oM.Analytical.Elements;
using BH.oM.Analytical.Results;
using BH.oM.Base;
Expand Down Expand Up @@ -119,6 +124,50 @@ private bool CreateObject(IBHoMObject obj)

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

[Description("Concatenates the last 7 characters of the ETABS Element GUID and the BHoM Object Name to get the Unique Name to assign to the ETABS Element.")]
private string SetUniqueName(BHoMObject obj, string name)
{
/* 1. CHECK OBJECT TYPE IS ACCEPTABLE */
if (!(obj.GetType() == typeof(Node) ||
obj.GetType() == typeof(Bar) ||
obj.GetType() == typeof(Panel) ||
obj.GetType() == typeof(Opening)))
{
return null;
}

/* 2. GET THE ETABS ELEMENT GUID */
int ret01 = 1;
int ret02 = 1;
string guid = null;
string tempObjName = "";

if (obj.GetType() == typeof(Node)) ret01 = m_model.PointObj.GetGUID(name, ref guid);
if (obj.GetType()== typeof(Bar)) ret01 = m_model.FrameObj.GetGUID(name, ref guid);
if (obj.GetType() == typeof(Panel) || obj.GetType() == typeof(Opening)) ret01 = m_model.AreaObj.GetGUID(name, ref guid);

/* 3. CREATE THE NEW UNIQUE NAME */
if (obj.Name == "")
{
tempObjName = guid.Substring(guid.Length - 7);
}
else
{
tempObjName = guid.Substring(guid.Length - 7) + "::" + obj.Name;
}

/* 4. ASSIGN THE NEW UNIQUE NAME TO THE ETABS ELEMENT */
if (obj.GetType() == typeof(Node)) ret02 = m_model.PointObj.ChangeName(name, tempObjName);
if (obj.GetType() == typeof(Bar)) ret02 = m_model.FrameObj.ChangeName(name, tempObjName);
if (obj.GetType() == typeof(Panel) || obj.GetType() == typeof(Opening)) ret02 = m_model.AreaObj.ChangeName(name, tempObjName);

if (!(ret01 == 0 && ret02 == 0)) return null;

return tempObjName;
}

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

private bool SetGroup(BHoMObject obj)
{
int ret = 0;
Expand Down
5 changes: 4 additions & 1 deletion Etabs_Adapter/CRUD/Read/Bar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ private List<Bar> ReadBar(List<string> ids = null)

try
{
Bar bhBar = new Bar();
string bhomName = GetBhomNameFromEtabsId(id);

Bar bhBar = new Bar() { Name = bhomName };

string startId = "";
string endId = "";
m_model.FrameObj.GetPoints(id, ref startId, ref endId);
Expand Down
5 changes: 4 additions & 1 deletion Etabs_Adapter/CRUD/Read/Link.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ private List<RigidLink> ReadRigidLink(List<string> ids = null)

foreach (KeyValuePair<string, List<string>> kvp in idDict)
{
RigidLink bhLink = new RigidLink();
string bhomName = GetBhomNameFromEtabsId(kvp.Key);

RigidLink bhLink = new RigidLink() { Name = bhomName};

SetAdapterId(bhLink, kvp.Key);

if (kvp.Value == null)
Expand Down
Loading