diff --git a/Etabs_Adapter/CRUD/Create/Bar.cs b/Etabs_Adapter/CRUD/Create/Bar.cs index b85ce405..33a8d56a 100644 --- a/Etabs_Adapter/CRUD/Create/Bar.cs +++ b/Etabs_Adapter/CRUD/Create/Bar.cs @@ -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); diff --git a/Etabs_Adapter/CRUD/Create/Link.cs b/Etabs_Adapter/CRUD/Create/Link.cs index 50a790d1..9670ee89 100644 --- a/Etabs_Adapter/CRUD/Create/Link.cs +++ b/Etabs_Adapter/CRUD/Create/Link.cs @@ -20,14 +20,17 @@ * along with this code. If not, see . */ -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 @@ -67,7 +70,12 @@ private bool CreateObject(RigidLink bhLink) linkIds.Add(name); } - multiId.Id = linkIds; + // Assign the Unique Name to the ETABS Element + List newLinkNames = SetUniqueName(bhLink, linkIds); + + if (newLinkNames == null) return false; + + multiId.Id = newLinkNames; bhLink.SetAdapterId(multiId); return success; @@ -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 SetUniqueName(RigidLink bhLink, List names) + { + + int ret01, ret02; + string guid = null; + string tempLinkName = ""; + List newLinkNames = new List(); + + 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; + } + + /***************************************************/ } } diff --git a/Etabs_Adapter/CRUD/Create/Node.cs b/Etabs_Adapter/CRUD/Create/Node.cs index 3bd54f38..f9266f7e 100644 --- a/Etabs_Adapter/CRUD/Create/Node.cs +++ b/Etabs_Adapter/CRUD/Create/Node.cs @@ -20,15 +20,18 @@ * along with this code. If not, see . */ -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 { @@ -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; @@ -106,6 +115,7 @@ private bool SetObject(Node bhNode, string name) } /***************************************************/ + } } diff --git a/Etabs_Adapter/CRUD/Create/Opening.cs b/Etabs_Adapter/CRUD/Create/Opening.cs index 245aa63e..bd2c1bcf 100644 --- a/Etabs_Adapter/CRUD/Create/Opening.cs +++ b/Etabs_Adapter/CRUD/Create/Opening.cs @@ -20,18 +20,21 @@ * along with this code. If not, see . */ -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 @@ -84,26 +87,32 @@ private bool CreateObject(Opening bhOpening) string openingName = GetAdapterId(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; } diff --git a/Etabs_Adapter/CRUD/Create/Panel.cs b/Etabs_Adapter/CRUD/Create/Panel.cs index 3868fefb..549525b5 100644 --- a/Etabs_Adapter/CRUD/Create/Panel.cs +++ b/Etabs_Adapter/CRUD/Create/Panel.cs @@ -20,17 +20,19 @@ * along with this code. If not, see . */ -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 @@ -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); @@ -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); @@ -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(); @@ -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; } @@ -198,6 +207,7 @@ private static void NonLinearEdgesCheck(List edges) } + /***************************************************/ } diff --git a/Etabs_Adapter/CRUD/Create/_Create.cs b/Etabs_Adapter/CRUD/Create/_Create.cs index 33340a73..8fdff387 100644 --- a/Etabs_Adapter/CRUD/Create/_Create.cs +++ b/Etabs_Adapter/CRUD/Create/_Create.cs @@ -20,13 +20,14 @@ * along with this code. If not, see . */ -using System.Collections.Generic; -using System.Linq; -using BH.oM.Structure.Elements; using BH.Engine.Adapters.ETABS; -using BH.oM.Adapters.ETABS.Elements; using BH.oM.Adapter; +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; namespace BH.Adapter.ETABS { @@ -109,6 +110,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; + } + + /***************************************************/ + } } diff --git a/Etabs_Adapter/CRUD/Read/Bar.cs b/Etabs_Adapter/CRUD/Read/Bar.cs index a677320c..4ba8d382 100644 --- a/Etabs_Adapter/CRUD/Read/Bar.cs +++ b/Etabs_Adapter/CRUD/Read/Bar.cs @@ -66,7 +66,10 @@ private List ReadBar(List 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); diff --git a/Etabs_Adapter/CRUD/Read/Link.cs b/Etabs_Adapter/CRUD/Read/Link.cs index 7b69c087..8054e6df 100644 --- a/Etabs_Adapter/CRUD/Read/Link.cs +++ b/Etabs_Adapter/CRUD/Read/Link.cs @@ -87,7 +87,10 @@ private List ReadRigidLink(List ids = null) foreach (KeyValuePair> 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) diff --git a/Etabs_Adapter/CRUD/Read/Node.cs b/Etabs_Adapter/CRUD/Read/Node.cs index 7e31c9c4..d5af9e3f 100644 --- a/Etabs_Adapter/CRUD/Read/Node.cs +++ b/Etabs_Adapter/CRUD/Read/Node.cs @@ -20,17 +20,18 @@ * along with this code. If not, see . */ -using System; using BH.Engine.Adapter; using BH.oM.Adapters.ETABS; +using BH.oM.Base; +using BH.oM.Structure.Constraints; +using BH.oM.Structure.Elements; +using System; using System.Collections; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; -using BH.oM.Base; -using BH.oM.Structure.Elements; -using BH.oM.Structure.Constraints; namespace BH.Adapter.ETABS @@ -72,7 +73,9 @@ private List ReadNode(List ids = null) Constraint6DOF support = GetConstraint6DOF(restraint, spring); - Node bhNode = new Node { Position = new oM.Geometry.Point() { X = x, Y = y, Z = z }, Support = support }; + string bhomName = GetBhomNameFromEtabsId(id); + + Node bhNode = new Node { Name = bhomName, Position = new oM.Geometry.Point() { X = x, Y = y, Z = z }, Support = support }; //Label and story string label = ""; @@ -117,7 +120,6 @@ public static Constraint6DOF GetConstraint6DOF(bool[] restraint, double[] spring return bhConstraint; } - /***************************************************/ } } diff --git a/Etabs_Adapter/CRUD/Read/Opening.cs b/Etabs_Adapter/CRUD/Read/Opening.cs index 2cb44820..934ad493 100644 --- a/Etabs_Adapter/CRUD/Read/Opening.cs +++ b/Etabs_Adapter/CRUD/Read/Opening.cs @@ -76,7 +76,9 @@ private List ReadOpening(List ids = null) ETABSId etabsId = new ETABSId(); etabsId.Id = id; - Opening opening = new Opening(); + string bhomName = GetBhomNameFromEtabsId(id); + + Opening opening = new Opening() { Name = bhomName }; Polyline pl = GetOpeningOutline(id); opening.Edges = pl.SubParts().Select(x => new Edge { Curve = x }).ToList(); diff --git a/Etabs_Adapter/CRUD/Read/Panel.cs b/Etabs_Adapter/CRUD/Read/Panel.cs index ba0dc67f..99331084 100644 --- a/Etabs_Adapter/CRUD/Read/Panel.cs +++ b/Etabs_Adapter/CRUD/Read/Panel.cs @@ -86,7 +86,9 @@ private List ReadPanel(List ids = null) panelProperty = bhomProperties[propertyName]; } - Panel panel = new Panel(); + string bhomName = GetBhomNameFromEtabsId(id); + + Panel panel = new Panel() { Name = bhomName }; Polyline pl = GetPanelPerimeter(id); panel.ExternalEdges = pl.SubParts().Select(x => new Edge { Curve = x }).ToList(); diff --git a/Etabs_Adapter/CRUD/Read/_Read.cs b/Etabs_Adapter/CRUD/Read/_Read.cs index 1f706111..a493e5e9 100644 --- a/Etabs_Adapter/CRUD/Read/_Read.cs +++ b/Etabs_Adapter/CRUD/Read/_Read.cs @@ -186,6 +186,20 @@ private static List FilterIds(IEnumerable ids, IEnumerable. */ -using System.Collections.Generic; -using System.Linq; using BH.Engine.Adapter; using BH.oM.Adapters.ETABS; using BH.oM.Structure.Elements; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Reflection.Emit; +using System.Xml.Linq; namespace BH.Adapter.ETABS @@ -77,7 +81,7 @@ private bool UpdateObjects(IEnumerable bhBars) } #endif - if (SetObject(bhBar)) + if (SetObject(bhBar) && UpdateUniqueName(bhBar)) ret++; } diff --git a/Etabs_Adapter/CRUD/Update/Node.cs b/Etabs_Adapter/CRUD/Update/Node.cs index 5ade95c4..51e4718a 100644 --- a/Etabs_Adapter/CRUD/Update/Node.cs +++ b/Etabs_Adapter/CRUD/Update/Node.cs @@ -20,14 +20,19 @@ * along with this code. If not, see . */ -using System.Collections.Generic; -using System.Linq; using BH.Engine.Adapter; -using BH.oM.Adapters.ETABS; -using BH.oM.Structure.Elements; -using BH.oM.Structure.Constraints; using BH.Engine.Adapters.ETABS; +using BH.Engine.Structure; +using BH.oM.Adapters.ETABS; using BH.oM.Physical.Elements; +using BH.oM.Structure.Constraints; +using BH.oM.Structure.Elements; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Xml.Linq; namespace BH.Adapter.ETABS { @@ -53,88 +58,95 @@ private bool UpdateObjects(IEnumerable nodes) Engine.Structure.NodeDistanceComparer comparer = AdapterComparers[typeof(Node)] // θ(1) as Engine.Structure.NodeDistanceComparer; - Dictionary> dx = new Dictionary>(); // θ(1) - Dictionary> dy = new Dictionary>(); // θ(1) - Dictionary> dz = new Dictionary>(); // θ(1) - - // 1. GROUP NODES BY RELATIVE MOVEMENT IN X/Y/Z DIRECTION - ** HASH TABLES ** foreach (Node bhNode in nodes) // n*θ(1) + θ(1) { string name = GetAdapterId(bhNode); // θ(1) + success = UpdatePosition(name, comparer, bhNode); // θ(1) + success = UpdateUniqueName(bhNode); // θ(1) + } - // Update position - double x = 0; // θ(1) - double y = 0; // θ(1) - double z = 0; // θ(1) + return success; // θ(1) + } - if (m_model.PointObj.GetCoordCartesian(name, ref x, ref y, ref z) == 0) // θ(1) - { - oM.Geometry.Point p = new oM.Geometry.Point() { X = x, Y = y, Z = z }; // θ(1) - - if (!comparer.Equals(bhNode, (Node)p)) // θ(1) - { - // Get BHoM vs ETABS differences in nodes coordinates - x = bhNode.Position.X - x; // θ(1) - y = bhNode.Position.Y - y; // θ(1) - z = bhNode.Position.Z - z; // θ(1) - - // Add Node name and corresponding dX in dx Hash Table - if (dx.ContainsKey(x)) dx[x].Add(name); // θ(1) - else dx.Add(x, new List() {name}); // θ(1) - // Add Node name and corresponding dY in dy Hash Table - if (dy.ContainsKey(y)) dy[y].Add(name); // θ(1) - else dy.Add(y, new List() {name}); // θ(1) - // Add Node name and corresponding dZ in dz Hash Table - if (dz.ContainsKey(z)) dz[z].Add(name); // θ(1) - else dz.Add(z, new List() {name}); // θ(1) - - } - } - } + + private bool UpdatePosition(string name, NodeDistanceComparer comparer, Node bhNode) + { + Dictionary> dx = new Dictionary>(); // θ(1) + Dictionary> dy = new Dictionary>(); // θ(1) + Dictionary> dz = new Dictionary>(); // θ(1) + + // Update position + double x = 0; // θ(1) + double y = 0; // θ(1) + double z = 0; // θ(1) + + if (m_model.PointObj.GetCoordCartesian(name, ref x, ref y, ref z) == 0) // θ(1) + { + oM.Geometry.Point p = new oM.Geometry.Point() { X = x, Y = y, Z = z }; // θ(1) + if (!comparer.Equals(bhNode, (Node)p)) // θ(1) + { + // Get BHoM vs ETABS differences in nodes coordinates + x = bhNode.Position.X - x; // θ(1) + y = bhNode.Position.Y - y; // θ(1) + z = bhNode.Position.Z - z; // θ(1) + + // Add Node name and corresponding dX in dx Hash Table + if (dx.ContainsKey(x)) dx[x].Add(name); // θ(1) + else dx.Add(x, new List() { name }); // θ(1) + // Add Node name and corresponding dY in dy Hash Table + if (dy.ContainsKey(y)) dy[y].Add(name); // θ(1) + else dy.Add(y, new List() { name }); // θ(1) + // Add Node name and corresponding dZ in dz Hash Table + if (dz.ContainsKey(z)) dz[z].Add(name); // θ(1) + else dz.Add(z, new List() { name }); // θ(1) + } + } + // 2. MOVE NODES GROUP-BY-GROUP - ** STREAMS ** // dX Movement dx.ToList().ForEach(kvp => // θ(n) - { + { // 1. Select all nodes belonging to same group kvp.Value.ForEach(pplbl => m_model.PointObj.SetSelected(pplbl.ToString(), true)); // 2. Move all selected nodes by same dX m_model.EditGeneral.Move((double)kvp.Key, 0, 0); // 3. Deselect all selected nodes kvp.Value.ForEach(pplbl => m_model.PointObj.SetSelected(pplbl.ToString(), false)); - }); + }); - // dY Movement - dy.ToList().ForEach(kvp => // θ(n) - { + // dY Movement + dy.ToList().ForEach(kvp => // θ(n) + { // 1. Select all nodes belonging to same group kvp.Value.ForEach(pplbl => m_model.PointObj.SetSelected(pplbl.ToString(), true)); // 2. Move all selected nodes by same dY m_model.EditGeneral.Move(0, (double)kvp.Key, 0); // 3. Deselect all selected nodes kvp.Value.ForEach(pplbl => m_model.PointObj.SetSelected(pplbl.ToString(), false)); - }); + }); - // dZ Movement - dz.ToList().ForEach(kvp => // θ(n) - { + // dZ Movement + dz.ToList().ForEach(kvp => // θ(n) + { // 1. Select all nodes belonging to same group kvp.Value.ForEach(pplbl => m_model.PointObj.SetSelected(pplbl.ToString(), true)); // 2. Move all selected nodes by same dZ m_model.EditGeneral.Move(0, 0, (double)kvp.Key); // 3. Deselect all selected nodes kvp.Value.ForEach(pplbl => m_model.PointObj.SetSelected(pplbl.ToString(), false)); - }); + }); - return success; - } + return true; + } /***************************************************/ + } } diff --git a/Etabs_Adapter/CRUD/Update/Panel.cs b/Etabs_Adapter/CRUD/Update/Panel.cs index 2b7158a2..d38af68e 100644 --- a/Etabs_Adapter/CRUD/Update/Panel.cs +++ b/Etabs_Adapter/CRUD/Update/Panel.cs @@ -20,16 +20,17 @@ * along with this code. If not, see . */ -using System.Collections.Generic; -using System.Linq; using BH.Engine.Adapter; -using BH.oM.Adapters.ETABS; -using BH.oM.Structure.Elements; using BH.Engine.Adapters.ETABS; -using BH.oM.Adapters.ETABS.Elements; +using BH.Engine.Structure; using BH.oM.Adapter; +using BH.oM.Adapters.ETABS; +using BH.oM.Adapters.ETABS.Elements; using BH.oM.Geometry; -using BH.Engine.Structure; +using BH.oM.Structure.Elements; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; namespace BH.Adapter.ETABS { @@ -85,6 +86,9 @@ private bool UpdateObjects(IEnumerable bhPanels) { m_model.AreaObj.SetDiaphragm(name, diaphragm.Name); } + + //Update Unique Name + UpdateUniqueName(bhPanel); } //Force refresh to make sure panel local orientation are set correctly diff --git a/Etabs_Adapter/CRUD/Update/_Update.cs b/Etabs_Adapter/CRUD/Update/_Update.cs index b993a14e..57fdefb8 100644 --- a/Etabs_Adapter/CRUD/Update/_Update.cs +++ b/Etabs_Adapter/CRUD/Update/_Update.cs @@ -20,18 +20,19 @@ * along with this code. If not, see . */ -using System.Collections.Generic; -using System.Linq; using BH.Engine.Adapter; +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 BH.oM.Structure.SectionProperties; using BH.oM.Structure.MaterialFragments; -using BH.Engine.Adapters.ETABS; -using BH.oM.Adapters.ETABS.Elements; -using BH.oM.Adapter; +using BH.oM.Structure.SectionProperties; using BH.oM.Structure.SurfaceProperties; -using BH.oM.Base; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; namespace BH.Adapter.ETABS { @@ -60,6 +61,47 @@ private bool UpdateObjects(IEnumerable objects) } /***************************************************/ + + [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 bool UpdateUniqueName(BHoMObject obj) + { + int ret01 = 1; + int ret02 = 1; + string guid = null; + string tempObjName = ""; + + /* 1. GET THE ETABS ELEMENT GUID */ + string uniqueName = GetAdapterId(obj); + + if (obj.GetType() == typeof(Node)) ret01 = m_model.PointObj.GetGUID(uniqueName, ref guid); + if (obj.GetType() == typeof(Bar)) ret01 = m_model.FrameObj.GetGUID(uniqueName, ref guid); + if (obj.GetType() == typeof(Panel) || obj.GetType() == typeof(Opening)) ret01 = m_model.AreaObj.GetGUID(uniqueName, ref guid); + + /* 2. CREATE THE NEW UNIQUE NAME */ + if (obj.Name == "") + { + tempObjName = guid.Substring(guid.Length - 7); + } + else + { + tempObjName = guid.Substring(guid.Length - 7) + "::" + obj.Name; + } + + /* 3. ASSIGN THE NEW UNIQUE NAME TO THE ETABS ELEMENT */ + if (obj.GetType() == typeof(Node)) ret02 = m_model.PointObj.ChangeName(uniqueName, tempObjName); + if (obj.GetType() == typeof(Bar)) ret02 = m_model.FrameObj.ChangeName(uniqueName, tempObjName); + if (obj.GetType() == typeof(Panel) || obj.GetType() == typeof(Opening)) ret02 = m_model.AreaObj.ChangeName(uniqueName, tempObjName); + + if (!(ret01 == 0 && ret02 == 0)) return false; + + ETABSId etabsIdFragment = new ETABSId { Id = tempObjName }; + + obj.SetAdapterId(etabsIdFragment); + + return true; + } + + /***************************************************/ } }