Skip to content
Closed
Show file tree
Hide file tree
Changes from 10 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
38 changes: 35 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 Expand Up @@ -215,6 +220,33 @@ private bool SetObject(Bar bhBar)

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

[Description("Concatenates the last 7 characters of the ETABS Element GUID and the Bar Name to get the Unique Name to assign to the ETABS Element.")]
private string SetUniqueName(Bar bhBar, string name) {

int ret01, ret02;
string guid = null;
string tempBarName = "";

ret01 = m_model.FrameObj.GetGUID(name, ref guid);

if (bhBar.Name == "")
{
tempBarName = guid.Substring(guid.Length - 7);
}
else
{
tempBarName = guid.Substring(guid.Length - 7) + "::" + bhBar.Name;
}

ret02 = m_model.FrameObj.ChangeName(name, tempBarName);

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

return tempBarName;
}

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

#if Debug16 || Release16

[Description("Returns a bar where the endpoints have been flipped without cloning the object")]
Expand Down
56 changes: 50 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,42 @@ 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) {

tempLinkName = "";
ret01 = m_model.LinkObj.GetGUID(name, ref guid);

if (bhLink.Name == "")
{
tempLinkName = guid.Substring(guid.Length - 7);
}
else
{
tempLinkName = guid.Substring(guid.Length - 7) + "::" + bhLink.Name;
}

ret02 = m_model.LinkObj.ChangeName(name, tempLinkName);

newLinkNames.Add(tempLinkName);

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

}

return newLinkNames;
}

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

Expand Down
55 changes: 46 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,34 @@ private bool SetObject(Node bhNode, string name)
}

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

[Description("Concatenates the last 7 characters of the ETABS Element GUID and the Node Name to get the Unique Name to assign to the ETABS Element.")]
private string SetUniqueName(Node bhNode, string name)
{

int ret01, ret02;
string guid = null;
string tempNodeName = "";

ret01 = m_model.PointObj.GetGUID(name, ref guid);

if (bhNode.Name == "")
{
tempNodeName = guid.Substring(guid.Length - 7);
}
else
{
tempNodeName = guid.Substring(guid.Length - 7) + "::" + bhNode.Name;
}

ret02 = m_model.PointObj.ChangeName(name, tempNodeName);

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

return tempNodeName;
}

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

Expand Down
58 changes: 47 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,31 +87,64 @@ 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;
}

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

[Description("Concatenates the last 7 characters of the ETABS Element GUID and the Opening Name to get the Unique Name to assign to the ETABS Element.")]
private string SetUniqueName(Opening bhOpening, string name)
{
int ret01, ret02;
string guid = null;
string tempOpeningName = "";

ret01 = m_model.AreaObj.GetGUID(name, ref guid);

if (bhOpening.Name == "")
{
tempOpeningName = guid.Substring(guid.Length - 7);
}
else
{
tempOpeningName = guid.Substring(guid.Length - 7) + "::" + bhOpening.Name;
}

ret02 = m_model.AreaObj.ChangeName(name, tempOpeningName);

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

return tempOpeningName;
}

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

}
}
Loading