Skip to content
Closed
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
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
60 changes: 54 additions & 6 deletions Etabs_Adapter/CRUD/Create/Link.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using System.Collections.Generic;
using System.Linq;
using BH.Engine.Adapter;
using BH.Engine.Adapters.ETABS;
using BH.Engine.Structure;
using BH.oM.Adapters.ETABS;
using BH.oM.Structure.Elements;
using BH.oM.Analytical.Elements;
using BH.oM.Structure.Constraints;
using BH.Engine.Structure;
using BH.Engine.Adapters.ETABS;
using BH.oM.Structure.Elements;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Xml.Linq;


namespace BH.Adapter.ETABS
Expand Down Expand Up @@ -67,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);

return success;
Expand Down Expand Up @@ -106,6 +114,46 @@ 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
28 changes: 19 additions & 9 deletions Etabs_Adapter/CRUD/Create/Node.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using System.Collections.Generic;
using System.Linq;
using BH.Engine.Adapter;
using BH.oM.Adapters.ETABS;
using BH.oM.Structure.Elements;
using BH.Engine.Structure;
using BH.Engine.Adapters.ETABS;
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 @@ -52,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);
}

return true;
Expand Down Expand Up @@ -106,6 +115,7 @@ private bool SetObject(Node bhNode, string name)
}

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

}
}

Expand Down
31 changes: 20 additions & 11 deletions Etabs_Adapter/CRUD/Create/Opening.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,21 @@
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using System.Collections.Generic;
using System.Linq;
using BH.Engine.Adapter;
using BH.oM.Adapters.ETABS;
using BH.oM.Structure.Elements;
using BH.Engine.Structure;
using BH.Engine.Adapters.ETABS;
using BH.Engine.Geometry;
using BH.Engine.Spatial;
using BH.Engine.Adapters.ETABS;
using BH.Engine.Structure;
using BH.oM.Adapters.ETABS;
using BH.oM.Adapters.ETABS.Elements;
using BH.oM.Geometry;
using BH.oM.Analytical.Elements;
using BH.oM.Data.Collections;
using BH.oM.Geometry;
using BH.oM.Structure.Elements;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Xml.Linq;


namespace BH.Adapter.ETABS
Expand Down Expand Up @@ -84,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);

return success;
}
Expand Down
38 changes: 24 additions & 14 deletions Etabs_Adapter/CRUD/Create/Panel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using System.Collections.Generic;
using System.Linq;
using BH.Engine.Adapter;
using BH.oM.Adapters.ETABS;
using BH.oM.Structure.Elements;
using BH.Engine.Structure;
using BH.Engine.Adapters.ETABS;
using BH.Engine.Geometry;
using BH.Engine.Spatial;
using BH.Engine.Adapters.ETABS;
using BH.Engine.Structure;
using BH.oM.Adapters.ETABS;
using BH.oM.Adapters.ETABS.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 Down Expand Up @@ -88,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 @@ -145,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 @@ -155,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 @@ -164,17 +172,18 @@ 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);
}

return success;
}

Expand All @@ -198,6 +207,7 @@ private static void NonLinearEdgesCheck(List<Edge> edges)

}


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

}
Expand Down
Loading