diff --git a/SAP2000_Adapter/Create/Bar.cs b/SAP2000_Adapter/CRUD/Create/Bar.cs similarity index 88% rename from SAP2000_Adapter/Create/Bar.cs rename to SAP2000_Adapter/CRUD/Create/Bar.cs index b154daa..70d8f73 100644 --- a/SAP2000_Adapter/Create/Bar.cs +++ b/SAP2000_Adapter/CRUD/Create/Bar.cs @@ -16,13 +16,14 @@ private bool CreateObject(Bar bhBar) { string name = ""; - if (m_model.FrameObj.AddByPoint(bhBar.StartNode.CustomData[AdapterId].ToString(), bhBar.EndNode.CustomData[AdapterId].ToString(), ref name, "Default", bhBar.Name.ToString()) == 0) + + if (m_model.FrameObj.AddByPoint(bhBar.StartNode.CustomData[AdapterIdName].ToString(), bhBar.EndNode.CustomData[AdapterIdName].ToString(), ref name, "Default", bhBar.Name.ToString()) == 0) { if (name != bhBar.Name & bhBar.Name != "") - Engine.Reflection.Compute.RecordNote($"Bar {bhBar.Name} was assigned {AdapterId} of {name}"); - bhBar.CustomData[AdapterId] = name; + Engine.Reflection.Compute.RecordNote($"Bar {bhBar.Name} was assigned {AdapterIdName} of {name}"); + bhBar.CustomData[AdapterIdName] = name; - string barProp = bhBar.SectionProperty != null ? bhBar.SectionProperty.CustomData[AdapterId].ToString() : "None"; + string barProp = bhBar.SectionProperty != null ? bhBar.SectionProperty.CustomData[AdapterIdName].ToString() : "None"; if (m_model.FrameObj.SetSection(name, barProp) != 0) { diff --git a/SAP2000_Adapter/Create/Errors.cs b/SAP2000_Adapter/CRUD/Create/Errors.cs similarity index 100% rename from SAP2000_Adapter/Create/Errors.cs rename to SAP2000_Adapter/CRUD/Create/Errors.cs diff --git a/SAP2000_Adapter/Create/Loads.cs b/SAP2000_Adapter/CRUD/Create/Loads.cs similarity index 91% rename from SAP2000_Adapter/Create/Loads.cs rename to SAP2000_Adapter/CRUD/Create/Loads.cs index 8f3a41b..6262285 100644 --- a/SAP2000_Adapter/Create/Loads.cs +++ b/SAP2000_Adapter/CRUD/Create/Loads.cs @@ -29,7 +29,7 @@ private bool CreateObject(Loadcase loadcase) m_model.LoadCases.StaticLinear.SetCase(loadcase.Name); m_model.LoadCases.StaticLinear.SetLoads(loadcase.Name, 1, ref loadTypes, ref loadNames, ref loadFactors); - loadcase.CustomData[AdapterId] = loadcase.Name; + loadcase.CustomData[AdapterIdName] = loadcase.Name; loadcase.Number = m_model.LoadPatterns.Count(); return true; @@ -42,15 +42,15 @@ private bool CreateObject(LoadCombination loadcombination) eCNameType nameType = eCNameType.LoadCase; if (m_model.RespCombo.Add(loadcombination.Name, 0) == 0) { - loadcombination.CustomData[AdapterId] = loadcombination.Name; + loadcombination.CustomData[AdapterIdName] = loadcombination.Name; foreach (Tuple comboCase in loadcombination.LoadCases) { double factor = comboCase.Item1; ICase bhomCase = comboCase.Item2; - if (!bhomCase.CustomData.ContainsKey(AdapterId)) - Engine.Reflection.Compute.RecordWarning($"case {bhomCase.Name} has no {AdapterId}. Try pushing the loadcase and using the result of that push to build the combo."); + if (!bhomCase.CustomData.ContainsKey(AdapterIdName)) + Engine.Reflection.Compute.RecordWarning($"case {bhomCase.Name} has no {AdapterIdName}. Try pushing the loadcase and using the result of that push to build the combo."); - if (m_model.RespCombo.SetCaseList(loadcombination.Name, ref nameType, bhomCase.CustomData[AdapterId].ToString(), factor) != 0) + if (m_model.RespCombo.SetCaseList(loadcombination.Name, ref nameType, bhomCase.CustomData[AdapterIdName].ToString(), factor) != 0) Engine.Reflection.Compute.RecordWarning("Could not add case " + bhomCase.Name + " to combo " + loadcombination.Name); } } @@ -74,7 +74,7 @@ private bool CreateObject(ILoad bhLoad) private bool CreateLoad(PointLoad bhLoad) { List nodes = bhLoad.Objects.Elements.ToList(); - string loadPat = bhLoad.Loadcase.CustomData[AdapterId].ToString(); + string loadPat = bhLoad.Loadcase.CustomData[AdapterIdName].ToString(); string cSys = bhLoad.Axis.ToCSI(); double[] val = { @@ -90,7 +90,7 @@ private bool CreateLoad(PointLoad bhLoad) foreach (Node bhNode in nodes) { - if (m_model.PointObj.SetLoadForce(bhNode.CustomData[AdapterId].ToString(), loadPat, ref val, replace, cSys, eItemType.Objects) != 0) + if (m_model.PointObj.SetLoadForce(bhNode.CustomData[AdapterIdName].ToString(), loadPat, ref val, replace, cSys, eItemType.Objects) != 0) { CreateElementError("Point Load", bhLoad.Name); } @@ -104,7 +104,7 @@ private bool CreateLoad(PointLoad bhLoad) private bool CreateLoad(BarUniformlyDistributedLoad bhLoad) { List bars = bhLoad.Objects.Elements.ToList(); - string loadPat = bhLoad.Loadcase.CustomData[AdapterId].ToString(); + string loadPat = bhLoad.Loadcase.CustomData[AdapterIdName].ToString(); double dist1 = 0; double dist2 = 1; int[] dirs = null; @@ -131,7 +131,7 @@ private bool CreateLoad(BarUniformlyDistributedLoad bhLoad) foreach (Bar bhBar in bars) { - string name = bhBar.CustomData[AdapterId].ToString(); + string name = bhBar.CustomData[AdapterIdName].ToString(); bool replaceNow = replace; for (int i = 0; i < dirs.Count(); i++) { @@ -151,7 +151,7 @@ private bool CreateLoad(BarUniformlyDistributedLoad bhLoad) private bool CreateLoad(AreaUniformlyDistributedLoad bhLoad) { List panels = bhLoad.Objects.Elements.ToList(); - string loadPat = bhLoad.Loadcase.CustomData[AdapterId].ToString(); + string loadPat = bhLoad.Loadcase.CustomData[AdapterIdName].ToString(); double[] vals = bhLoad.Pressure.ToDoubleArray(); int[] dirs = null; switch (bhLoad.Axis) @@ -176,7 +176,7 @@ private bool CreateLoad(AreaUniformlyDistributedLoad bhLoad) foreach (Panel panel in panels) { - string name = panel.CustomData[AdapterId].ToString(); + string name = panel.CustomData[AdapterIdName].ToString(); bool replaceNow = replace; for (int i = 0; i < dirs.Count(); i++) { @@ -196,7 +196,7 @@ public void SetLoad(GravityLoad gravityLoad, bool replace) double selfWeightExisting = 0; double selfWeightNew = -gravityLoad.GravityDirection.Z; - string caseName = gravityLoad.Loadcase.CustomData[AdapterId].ToString(); + string caseName = gravityLoad.Loadcase.CustomData[AdapterIdName].ToString(); m_model.LoadPatterns.GetSelfWTMultiplier(caseName, ref selfWeightExisting); diff --git a/SAP2000_Adapter/Create/Material.cs b/SAP2000_Adapter/CRUD/Create/Material.cs similarity index 95% rename from SAP2000_Adapter/Create/Material.cs rename to SAP2000_Adapter/CRUD/Create/Material.cs index 12edfc8..9cfa516 100644 --- a/SAP2000_Adapter/Create/Material.cs +++ b/SAP2000_Adapter/CRUD/Create/Material.cs @@ -25,11 +25,11 @@ private bool CreateObject(IMaterialFragment material) if (m_model.PropMaterial.AddMaterial(ref name, matType, "United States", material.Name, material.Name, guid) == 0) //try to get the material from a dataset { - material.CustomData[AdapterId] = name; + material.CustomData[AdapterIdName] = name; } else if (m_model.PropMaterial.SetMaterial(material.Name, matType, color, notes, guid) == 0) //create the material { - material.CustomData[AdapterId] = material.Name; + material.CustomData[AdapterIdName] = material.Name; if (material is IIsotropic) { diff --git a/SAP2000_Adapter/Create/Node.cs b/SAP2000_Adapter/CRUD/Create/Node.cs similarity index 92% rename from SAP2000_Adapter/Create/Node.cs rename to SAP2000_Adapter/CRUD/Create/Node.cs index b20748e..e3f7f1a 100644 --- a/SAP2000_Adapter/Create/Node.cs +++ b/SAP2000_Adapter/CRUD/Create/Node.cs @@ -18,8 +18,8 @@ private bool CreateObject(Node bhNode) if (m_model.PointObj.AddCartesian(bhNode.Position.X, bhNode.Position.Y, bhNode.Position.Z, ref name, bhNode.Name.ToString()) == 0) { if (name != bhNode.Name) - Engine.Reflection.Compute.RecordNote($"Node {bhNode.Name} was assigned {AdapterId} of {name}"); - bhNode.CustomData[AdapterId] = name; + Engine.Reflection.Compute.RecordNote($"Node {bhNode.Name} was assigned {AdapterIdName} of {name}"); + bhNode.CustomData[AdapterIdName] = name; if (bhNode.Support != null) { diff --git a/SAP2000_Adapter/Create/Panel.cs b/SAP2000_Adapter/CRUD/Create/Panel.cs similarity index 91% rename from SAP2000_Adapter/Create/Panel.cs rename to SAP2000_Adapter/CRUD/Create/Panel.cs index fddbe7b..8dcdfe3 100644 --- a/SAP2000_Adapter/Create/Panel.cs +++ b/SAP2000_Adapter/CRUD/Create/Panel.cs @@ -28,10 +28,10 @@ private bool CreateObject(Panel bhPanel) if (m_model.AreaObj.AddByCoord(segmentCount, ref x, ref y, ref z, ref name, "Default", bhPanel.Name.ToString()) == 0) { if (name != bhPanel.Name & bhPanel.Name != "") - Engine.Reflection.Compute.RecordNote($"Panel {bhPanel.Name} was assigned {AdapterId} of {name}"); - bhPanel.CustomData[AdapterId] = name; + Engine.Reflection.Compute.RecordNote($"Panel {bhPanel.Name} was assigned {AdapterIdName} of {name}"); + bhPanel.CustomData[AdapterIdName] = name; - string propName = bhPanel.Property.CustomData[AdapterId].ToString(); + string propName = bhPanel.Property.CustomData[AdapterIdName].ToString(); if (m_model.AreaObj.SetProperty(name, propName, 0) != 0) CreatePropertyError("Surface Property", "Panel", name); } diff --git a/SAP2000_Adapter/Create/RigidLink.cs b/SAP2000_Adapter/CRUD/Create/RigidLink.cs similarity index 84% rename from SAP2000_Adapter/Create/RigidLink.cs rename to SAP2000_Adapter/CRUD/Create/RigidLink.cs index 4b814de..4b48a77 100644 --- a/SAP2000_Adapter/Create/RigidLink.cs +++ b/SAP2000_Adapter/CRUD/Create/RigidLink.cs @@ -20,8 +20,8 @@ private bool CreateObject(RigidLink bhLink) Node masterNode = link.MasterNode; Node slaveNode = link.SlaveNodes[0]; - if ( m_model.LinkObj.AddByPoint(masterNode.CustomData[AdapterId].ToString(), - slaveNode.CustomData[AdapterId].ToString(), ref name, false, "Default") != 0) + if ( m_model.LinkObj.AddByPoint(masterNode.CustomData[AdapterIdName].ToString(), + slaveNode.CustomData[AdapterIdName].ToString(), ref name, false, "Default") != 0) { CreateElementError("RigidLink", name); } @@ -29,7 +29,7 @@ private bool CreateObject(RigidLink bhLink) linkIds.Add(name); } - bhLink.CustomData[AdapterId] = linkIds; + bhLink.CustomData[AdapterIdName] = linkIds; return true; } diff --git a/SAP2000_Adapter/Create/Section.cs b/SAP2000_Adapter/CRUD/Create/Section.cs similarity index 99% rename from SAP2000_Adapter/Create/Section.cs rename to SAP2000_Adapter/CRUD/Create/Section.cs index c88b1ee..3f45259 100644 --- a/SAP2000_Adapter/Create/Section.cs +++ b/SAP2000_Adapter/CRUD/Create/Section.cs @@ -17,7 +17,7 @@ private bool CreateObject(ISectionProperty bhomSection) { if (SetSection(bhomSection as dynamic)) { - bhomSection.CustomData[AdapterId] = bhomSection.Name; + bhomSection.CustomData[AdapterIdName] = bhomSection.Name; return true; } else { return false; } diff --git a/SAP2000_Adapter/Create/SurfaceProperty.cs b/SAP2000_Adapter/CRUD/Create/SurfaceProperty.cs similarity index 93% rename from SAP2000_Adapter/Create/SurfaceProperty.cs rename to SAP2000_Adapter/CRUD/Create/SurfaceProperty.cs index 9466bc9..3ceb68a 100644 --- a/SAP2000_Adapter/Create/SurfaceProperty.cs +++ b/SAP2000_Adapter/CRUD/Create/SurfaceProperty.cs @@ -10,7 +10,7 @@ public partial class SAP2000Adapter /***************************************************/ private bool CreateObject(ISurfaceProperty surfaceProperty) { - string materialName = surfaceProperty.Material.CustomData[AdapterId].ToString(); + string materialName = surfaceProperty.Material.CustomData[AdapterIdName].ToString(); if (surfaceProperty.GetType() == typeof(Waffle)) { @@ -32,12 +32,12 @@ private bool CreateObject(ISurfaceProperty surfaceProperty) ConstantThickness constantThickness = (ConstantThickness)surfaceProperty; int shellType = 1; bool includeDrillingDOF = true; - string material = constantThickness.Material.CustomData[AdapterId].ToString(); + string material = constantThickness.Material.CustomData[AdapterIdName].ToString(); if (m_model.PropArea.SetShell_1(surfaceProperty.Name, shellType, includeDrillingDOF, material, 0, constantThickness.Thickness, constantThickness.Thickness) != 0) CreatePropertyError("ConstantThickness", "SurfaceProperty", surfaceProperty.Name); } - surfaceProperty.CustomData[AdapterId] = surfaceProperty.Name; + surfaceProperty.CustomData[AdapterIdName] = surfaceProperty.Name; if (surfaceProperty.HasModifiers()) { diff --git a/SAP2000_Adapter/Create/_Create.cs b/SAP2000_Adapter/CRUD/Create/_ICreate.cs similarity index 92% rename from SAP2000_Adapter/Create/_Create.cs rename to SAP2000_Adapter/CRUD/Create/_ICreate.cs index d1c0f2b..4e2604d 100644 --- a/SAP2000_Adapter/Create/_Create.cs +++ b/SAP2000_Adapter/CRUD/Create/_ICreate.cs @@ -11,6 +11,7 @@ using System.Collections.Generic; using System.Linq; using BH.oM.Analytical; +using BH.oM.Adapter; namespace BH.Adapter.SAP2000 { @@ -20,7 +21,7 @@ public partial class SAP2000Adapter /**** Adapter overload method ****/ /***************************************************/ - protected override bool Create(IEnumerable objects) + protected override bool ICreate(IEnumerable objects, ActionConfig actionConfig = null) { bool success = true; diff --git a/SAP2000_Adapter/Read/Bar.cs b/SAP2000_Adapter/CRUD/Read/Bar.cs similarity index 96% rename from SAP2000_Adapter/Read/Bar.cs rename to SAP2000_Adapter/CRUD/Read/Bar.cs index 682ed31..86d7e50 100644 --- a/SAP2000_Adapter/Read/Bar.cs +++ b/SAP2000_Adapter/CRUD/Read/Bar.cs @@ -16,8 +16,8 @@ private List ReadBars(List ids = null) { List bhomBars = new List(); - Dictionary bhomNodes = ReadNodes().ToDictionary(x => x.CustomData[AdapterId].ToString()); - Dictionary bhomSections = ReadSectionProperties().ToDictionary(x => x.CustomData[AdapterId].ToString()); + Dictionary bhomNodes = ReadNodes().ToDictionary(x => x.CustomData[AdapterIdName].ToString()); + Dictionary bhomSections = ReadSectionProperties().ToDictionary(x => x.CustomData[AdapterIdName].ToString()); int nameCount = 0; string[] names = { }; @@ -33,7 +33,7 @@ private List ReadBars(List ids = null) try { Bar bhomBar = new Bar(); - bhomBar.CustomData[AdapterId] = id; + bhomBar.CustomData[AdapterIdName] = id; string startId = ""; string endId = ""; m_model.FrameObj.GetPoints(id, ref startId, ref endId); diff --git a/SAP2000_Adapter/Read/Errors.cs b/SAP2000_Adapter/CRUD/Read/Errors.cs similarity index 100% rename from SAP2000_Adapter/Read/Errors.cs rename to SAP2000_Adapter/CRUD/Read/Errors.cs diff --git a/SAP2000_Adapter/Read/LinkConstraint.cs b/SAP2000_Adapter/CRUD/Read/LinkConstraint.cs similarity index 98% rename from SAP2000_Adapter/Read/LinkConstraint.cs rename to SAP2000_Adapter/CRUD/Read/LinkConstraint.cs index 98d4931..e901911 100644 --- a/SAP2000_Adapter/Read/LinkConstraint.cs +++ b/SAP2000_Adapter/CRUD/Read/LinkConstraint.cs @@ -80,7 +80,7 @@ private LinkConstraint GetLinearLinkConstraint(string name) m_model.PropLink.GetLinear(name, ref dof, ref fix, ref stiff, ref damp, ref dj2, ref dj3, ref stiffCoupled, ref dampCoupled, ref notes, ref guid); constraint.Name = name; - constraint.CustomData[AdapterId] = name; + constraint.CustomData[AdapterIdName] = name; constraint.XtoX = fix[0]; constraint.ZtoZ = fix[1]; constraint.YtoY = fix[2]; diff --git a/SAP2000_Adapter/Read/Loads.cs b/SAP2000_Adapter/CRUD/Read/Loads.cs similarity index 97% rename from SAP2000_Adapter/Read/Loads.cs rename to SAP2000_Adapter/CRUD/Read/Loads.cs index db56f7e..44e78c2 100644 --- a/SAP2000_Adapter/Read/Loads.cs +++ b/SAP2000_Adapter/CRUD/Read/Loads.cs @@ -39,7 +39,7 @@ private List ReadLoadcase(List ids = null) else { Loadcase bhomCase = BH.Engine.Structure.Create.Loadcase(names[i], i, patternType.ToBHoM()); - bhomCase.CustomData[AdapterId] = names[i]; + bhomCase.CustomData[AdapterIdName] = names[i]; loadCases.Add(bhomCase); } } @@ -53,7 +53,7 @@ private List ReadLoadCombination(List ids = null) { List combinations = new List(); - Dictionary bhomCases = ReadLoadcase().ToDictionary(x => x.CustomData[AdapterId].ToString()); + Dictionary bhomCases = ReadLoadcase().ToDictionary(x => x.CustomData[AdapterIdName].ToString()); int count = 0; string[] names = null; @@ -78,7 +78,7 @@ private List ReadLoadCombination(List ids = null) Name = names[i], Number = i, }; - bhomCombo.CustomData[AdapterId] = names[i]; + bhomCombo.CustomData[AdapterIdName] = names[i]; if (caseCount > 0) { List comboCases = new List(); @@ -124,7 +124,7 @@ private List ReadPointLoad(List ids = null) List loads = new List(); Dictionary bhomCases = ReadLoadcase().ToDictionary(x => x.Name.ToString()); - Dictionary bhomNodes = ReadNodes().ToDictionary(x => x.CustomData[AdapterId].ToString()); + Dictionary bhomNodes = ReadNodes().ToDictionary(x => x.CustomData[AdapterIdName].ToString()); int count = 0; string[] nodeNames = null; @@ -166,7 +166,7 @@ private List ReadBarLoad(List ids = null) List loads = new List(); Dictionary bhomCases = ReadLoadcase().ToDictionary(x => x.Name.ToString()); - Dictionary bhomBars = ReadBars().ToDictionary(x => x.CustomData[AdapterId].ToString()); + Dictionary bhomBars = ReadBars().ToDictionary(x => x.CustomData[AdapterIdName].ToString()); int count = 0; string[] frameNames = null; @@ -262,7 +262,7 @@ private List ReadAreaLoad(List ids = null) List loads = new List(); Dictionary bhomCases = ReadLoadcase().ToDictionary(x => x.Name.ToString()); - Dictionary bhomPanels = ReadPanel().ToDictionary(x => x.CustomData[AdapterId].ToString()); + Dictionary bhomPanels = ReadPanel().ToDictionary(x => x.CustomData[AdapterIdName].ToString()); int count = 0; string[] areaNames = null; diff --git a/SAP2000_Adapter/Read/Material.cs b/SAP2000_Adapter/CRUD/Read/Material.cs similarity index 98% rename from SAP2000_Adapter/Read/Material.cs rename to SAP2000_Adapter/CRUD/Read/Material.cs index fe564e4..09027fc 100644 --- a/SAP2000_Adapter/Read/Material.cs +++ b/SAP2000_Adapter/CRUD/Read/Material.cs @@ -119,7 +119,7 @@ private List ReadMaterial(List ids = null) break; } - m.CustomData.Add(AdapterId, materialName); + m.CustomData.Add(AdapterIdName, materialName); materialList.Add(m); } diff --git a/SAP2000_Adapter/Read/Node.cs b/SAP2000_Adapter/CRUD/Read/Node.cs similarity index 96% rename from SAP2000_Adapter/Read/Node.cs rename to SAP2000_Adapter/CRUD/Read/Node.cs index af95e1a..0f28176 100644 --- a/SAP2000_Adapter/Read/Node.cs +++ b/SAP2000_Adapter/CRUD/Read/Node.cs @@ -35,7 +35,7 @@ private List ReadNodes(List ids = null) m_model.PointObj.GetCoordCartesian(id, ref x, ref y, ref z); bhNode.Position = Engine.Geometry.Create.Point(x, y, z); - bhNode.CustomData[AdapterId] = id; + bhNode.CustomData[AdapterIdName] = id; m_model.PointObj.GetRestraint(id, ref restraint); m_model.PointObj.SetSpring(id, ref spring); diff --git a/SAP2000_Adapter/Read/Panel.cs b/SAP2000_Adapter/CRUD/Read/Panel.cs similarity index 94% rename from SAP2000_Adapter/Read/Panel.cs rename to SAP2000_Adapter/CRUD/Read/Panel.cs index 8a7cc19..9bbb51b 100644 --- a/SAP2000_Adapter/Read/Panel.cs +++ b/SAP2000_Adapter/CRUD/Read/Panel.cs @@ -17,8 +17,8 @@ private List ReadPanel(List ids = null) { List bhomPanels = new List(); - Dictionary bhomNodes = ReadNodes().ToDictionary(x => x.CustomData[AdapterId].ToString()); - Dictionary bhomProperties = ReadSurfaceProperty().ToDictionary(x => x.CustomData[AdapterId].ToString()); + Dictionary bhomNodes = ReadNodes().ToDictionary(x => x.CustomData[AdapterIdName].ToString()); + Dictionary bhomProperties = ReadSurfaceProperty().ToDictionary(x => x.CustomData[AdapterIdName].ToString()); if (ids == null) { @@ -51,7 +51,7 @@ private List ReadPanel(List ids = null) Panel bhomPanel = BH.Engine.Structure.Create.Panel(outEdges, noOpenings, bhomProperties[propertyName], id); //Set the properties - bhomPanel.CustomData[AdapterId] = id; + bhomPanel.CustomData[AdapterIdName] = id; //Add the panel to the list bhomPanels.Add(bhomPanel); diff --git a/SAP2000_Adapter/Read/RigidLink.cs b/SAP2000_Adapter/CRUD/Read/RigidLink.cs similarity index 97% rename from SAP2000_Adapter/Read/RigidLink.cs rename to SAP2000_Adapter/CRUD/Read/RigidLink.cs index e78212c..853edfa 100644 --- a/SAP2000_Adapter/Read/RigidLink.cs +++ b/SAP2000_Adapter/CRUD/Read/RigidLink.cs @@ -14,7 +14,7 @@ public partial class SAP2000Adapter private List ReadRigidLink(List ids = null) { List linkList = new List(); - Dictionary bhomNodes = ReadNodes().ToDictionary(x => x.CustomData[AdapterId].ToString()); + Dictionary bhomNodes = ReadNodes().ToDictionary(x => x.CustomData[AdapterIdName].ToString()); //Read all links, filter by id at end, so that we can join multi-links. int nameCount = 0; diff --git a/SAP2000_Adapter/Read/Section.cs b/SAP2000_Adapter/CRUD/Read/Section.cs similarity index 98% rename from SAP2000_Adapter/Read/Section.cs rename to SAP2000_Adapter/CRUD/Read/Section.cs index 9743a15..b520138 100644 --- a/SAP2000_Adapter/Read/Section.cs +++ b/SAP2000_Adapter/CRUD/Read/Section.cs @@ -20,7 +20,7 @@ public partial class SAP2000Adapter private List ReadSectionProperties(List ids = null) { List propList = new List(); - Dictionary bhomMaterials = ReadMaterial().ToDictionary(x => x.CustomData[AdapterId].ToString()); + Dictionary bhomMaterials = ReadMaterial().ToDictionary(x => x.CustomData[AdapterIdName].ToString()); int nameCount = 0; string[] names = { }; @@ -224,7 +224,7 @@ private List ReadSectionProperties(List ids = null) bhomProperty.Material = material; bhomProperty.Name = id; - bhomProperty.CustomData[AdapterId] = id; + bhomProperty.CustomData[AdapterIdName] = id; propList.Add(bhomProperty); } diff --git a/SAP2000_Adapter/Read/SurfaceProperty.cs b/SAP2000_Adapter/CRUD/Read/SurfaceProperty.cs similarity index 96% rename from SAP2000_Adapter/Read/SurfaceProperty.cs rename to SAP2000_Adapter/CRUD/Read/SurfaceProperty.cs index f7652ac..ed022cd 100644 --- a/SAP2000_Adapter/Read/SurfaceProperty.cs +++ b/SAP2000_Adapter/CRUD/Read/SurfaceProperty.cs @@ -15,7 +15,7 @@ private List ReadSurfaceProperty(List ids = null) { List propertyList = new List(); - Dictionary bhomMaterials = ReadMaterial().ToDictionary(x => x.CustomData[AdapterId].ToString()); + Dictionary bhomMaterials = ReadMaterial().ToDictionary(x => x.CustomData[AdapterIdName].ToString()); int nameCount = 0; string[] nameArr = { }; @@ -48,7 +48,7 @@ private List ReadSurfaceProperty(List ids = null) else { ConstantThickness panelConstant = new ConstantThickness(); - panelConstant.CustomData[AdapterId] = id; + panelConstant.CustomData[AdapterIdName] = id; panelConstant.Name = id; panelConstant.Material = bhomMaterials[materialName]; panelConstant.Thickness = thickness; diff --git a/SAP2000_Adapter/Read/_Read.cs b/SAP2000_Adapter/CRUD/Read/_IRead.cs similarity index 88% rename from SAP2000_Adapter/Read/_Read.cs rename to SAP2000_Adapter/CRUD/Read/_IRead.cs index bfb3ba9..a4d5cee 100644 --- a/SAP2000_Adapter/Read/_Read.cs +++ b/SAP2000_Adapter/CRUD/Read/_IRead.cs @@ -10,6 +10,7 @@ using System.Collections; using System.Collections.Generic; using System.Linq; +using BH.oM.Adapter; namespace BH.Adapter.SAP2000 { @@ -18,8 +19,8 @@ public partial class SAP2000Adapter /***************************************************/ /**** Adapter overload method ****/ /***************************************************/ - - protected override IEnumerable Read(Type type, IList ids) + + protected override IEnumerable IRead(Type type, IList ids, ActionConfig actionConfig = null) { if (type == typeof(Node)) return ReadNodes(ids as dynamic); @@ -45,7 +46,7 @@ protected override IEnumerable Read(Type type, IList ids) return ReadLinkConstraints(ids as dynamic); - return null;//<--- returning null will throw error in replace method of BHOM_Adapter line 34: can't do typeof(null) - returning null does seem the most sensible to return though + return null; } /***************************************************/ diff --git a/SAP2000_Adapter/Delete/Delete.cs b/SAP2000_Adapter/Delete/Delete.cs deleted file mode 100644 index cb7279c..0000000 --- a/SAP2000_Adapter/Delete/Delete.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BH.Adapter.SAP2000 -{ - public partial class SAP2000Adapter - { - /***************************************************/ - /**** Public Methods ****/ - /***************************************************/ - - protected override int Delete(Type type, IEnumerable ids) - { - return 0; - throw new NotImplementedException(); - } - - /***************************************************/ - } -} diff --git a/SAP2000_Adapter/SAP2000Adapter.cs b/SAP2000_Adapter/SAP2000Adapter.cs index e32adfb..45a79bf 100644 --- a/SAP2000_Adapter/SAP2000Adapter.cs +++ b/SAP2000_Adapter/SAP2000Adapter.cs @@ -4,6 +4,9 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using BH.oM.Adapter; +using BH.Engine.Adapter; +using BH.oM.Adapters.SAP2000; namespace BH.Adapter.SAP2000 { @@ -12,8 +15,8 @@ public partial class SAP2000Adapter : BHoMAdapter /***************************************************/ /**** Public Properties ****/ /***************************************************/ - - public const string ID = "SAP2000_id"; + + public SAP2000ActionConfig SAPConfig { get; set; } = new SAP2000ActionConfig(); /***************************************************/ /**** Constructors ****/ @@ -21,11 +24,15 @@ public partial class SAP2000Adapter : BHoMAdapter public SAP2000Adapter(string filePath = "", bool Active = false) { - if (Active) - { - AdapterId = ID; + //Initialization + AdapterIdName = Engine.SAP2000.Convert.AdapterIdName; + Modules.Structure.ModuleLoader.LoadModules(this); + SetupComparers(); + SetupDependencies(); + if (Active) + { string pathToSAP = @"C:\Program Files\Computers and Structures\SAP2000 21\SAP2000.exe"; cHelper helper = new Helper(); @@ -68,6 +75,7 @@ public SAP2000Adapter(string filePath = "", bool Active = false) private cOAPI m_app; private cSapModel m_model; + private ActionConfig actionConfig; /***************************************************/ } diff --git a/SAP2000_Adapter/SAP2000_Adapter.csproj b/SAP2000_Adapter/SAP2000_Adapter.csproj index de65922..e892c24 100644 --- a/SAP2000_Adapter/SAP2000_Adapter.csproj +++ b/SAP2000_Adapter/SAP2000_Adapter.csproj @@ -35,6 +35,12 @@ ..\..\BHoM\Build\Acoustic_oM.dll False + + ..\..\BHoM_Adapter\Build\Adapter_Engine.dll + + + ..\..\BHoM_Adapter\Build\Adapter_oM.dll + ..\..\BHoM\Build\Analytical_oM.dll False @@ -129,6 +135,9 @@ ..\..\BHoM_Engine\Build\Serialiser_Engine.dll False + + ..\..\BHoM_Adapter\Build\Structure_AdapterModules.dll + ..\..\BHoM_Engine\Build\Structure_Engine.dll False @@ -147,38 +156,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - + + + {bc975b64-e35e-4155-a067-7a88505e61c2} diff --git a/SAP2000_Adapter/Types/Comparer.cs b/SAP2000_Adapter/Types/Comparer.cs deleted file mode 100644 index 494411b..0000000 --- a/SAP2000_Adapter/Types/Comparer.cs +++ /dev/null @@ -1,65 +0,0 @@ -using BH.Engine.Base.Objects; -using BH.oM.Structure.MaterialFragments; -using BH.oM.Structure.Elements; -using BH.oM.Structure.Constraints; -using BH.oM.Structure.SectionProperties; -using BH.oM.Structure.SurfaceProperties; -using BH.oM.Structure.Loads; -using System; -using System.Collections.Generic; - -namespace BH.Adapter.SAP2000 -{ - public partial class SAP2000Adapter - { - /***************************************************/ - /**** BHoM Adapter Interface ****/ - /***************************************************/ - - //Standard implementation of the comparer class. - //Compares nodes by distance (down to 3 decimal places -> mm) - //Compares Materials, SectionProprties, LinkConstraints, and Property2D by name - //Add/remove any type in the dictionary below that you want (or not) a specific comparison method for - - protected override IEqualityComparer Comparer() - { - Type type = typeof(T); - - if (m_Comparers.ContainsKey(type)) - return m_Comparers[type] as IEqualityComparer; - - else if (type.BaseType != null && m_Comparers.ContainsKey(type.BaseType)) - return m_Comparers[type.BaseType] as IEqualityComparer; - - else - { - foreach (Type interType in type.GetInterfaces()) - { - if (m_Comparers.ContainsKey(interType)) - return m_Comparers[interType] as IEqualityComparer; - } - - return EqualityComparer.Default; - } - } - - - /***************************************************/ - /**** Private Fields ****/ - /***************************************************/ - - private static Dictionary m_Comparers = new Dictionary - { - {typeof(Node), new BH.Engine.Structure.NodeDistanceComparer(3) }, //The 3 in here sets how many decimal places to look at for node merging. 3 decimal places gives mm precision - {typeof(ISectionProperty), new BHoMObjectNameOrToStringComparer() }, - {typeof(IMaterialFragment), new BHoMObjectNameComparer() }, - {typeof(LinkConstraint), new BHoMObjectNameComparer() }, - {typeof(ISurfaceProperty), new BHoMObjectNameComparer() }, - {typeof(ICase), new BHoMObjectNameComparer() }, - - }; - - - /***************************************************/ - } -} \ No newline at end of file diff --git a/SAP2000_Adapter/Types/DependencyTypes.cs b/SAP2000_Adapter/Types/DependencyTypes.cs deleted file mode 100644 index 6d3910b..0000000 --- a/SAP2000_Adapter/Types/DependencyTypes.cs +++ /dev/null @@ -1,61 +0,0 @@ -using BH.oM.Structure.MaterialFragments; -using BH.oM.Structure.Elements; -using BH.oM.Structure.Constraints; -using BH.oM.Structure.SectionProperties; -using BH.oM.Structure.SurfaceProperties; -using BH.oM.Structure.Loads; -using System; -using System.Collections.Generic; - -namespace BH.Adapter.SAP2000 -{ - public partial class SAP2000Adapter - { - /***************************************************/ - /**** BHoM Adapter Interface ****/ - /***************************************************/ - - //Standard implementation for dependency types (change the dictionary below to override): - - protected override List DependencyTypes() - { - Type type = typeof(T); - - if (m_DependencyTypes.ContainsKey(type)) - return m_DependencyTypes[type]; - - else if (type.BaseType != null && m_DependencyTypes.ContainsKey(type.BaseType)) - return m_DependencyTypes[type.BaseType]; - - else - { - foreach (Type interType in type.GetInterfaces()) - { - if (m_DependencyTypes.ContainsKey(interType)) - return m_DependencyTypes[interType]; - } - } - - - return new List(); - } - - - /***************************************************/ - /**** Private Fields ****/ - /***************************************************/ - - private static Dictionary> m_DependencyTypes = new Dictionary> - { - {typeof(Bar), new List { typeof(ISectionProperty), typeof(Node) } }, - {typeof(ISectionProperty), new List { typeof(IMaterialFragment) } }, - {typeof(Panel), new List { typeof(ISurfaceProperty) } }, - {typeof(ISurfaceProperty), new List { typeof(IMaterialFragment) } }, - {typeof(RigidLink), new List { typeof(LinkConstraint), typeof(Node) } }, - {typeof(ILoad), new List {typeof(Loadcase) } }, - {typeof(LoadCombination), new List {typeof(Loadcase) } } - }; - - /***************************************************/ - } -} diff --git a/SAP2000_Adapter/Types/NextId.cs b/SAP2000_Adapter/Types/NextId.cs deleted file mode 100644 index 97cba0b..0000000 --- a/SAP2000_Adapter/Types/NextId.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace BH.Adapter.SAP2000 -{ - public partial class SAP2000Adapter - { - /***************************************************/ - /**** Adapter overload method ****/ - /***************************************************/ - - private Dictionary idDictionary = new Dictionary(); - - protected override object NextId(Type objectType, bool refresh = false) - { - return -1; - } - } -} diff --git a/SAP2000_Adapter/Types/SetupComparer.cs b/SAP2000_Adapter/Types/SetupComparer.cs new file mode 100644 index 0000000..d4807b6 --- /dev/null +++ b/SAP2000_Adapter/Types/SetupComparer.cs @@ -0,0 +1,38 @@ +using BH.Engine.Base.Objects; +using BH.oM.Structure.MaterialFragments; +using BH.oM.Structure.Elements; +using BH.oM.Structure.Constraints; +using BH.oM.Structure.SectionProperties; +using BH.oM.Structure.SurfaceProperties; +using BH.oM.Structure.Loads; +using System; +using System.Collections.Generic; + +namespace BH.Adapter.SAP2000 +{ + public partial class SAP2000Adapter + { + /***************************************************/ + /**** BHoM Adapter Interface ****/ + /***************************************************/ + + //Compares nodes by distance (down to 3 decimal places -> mm) + //Compares Materials, SectionProprties, LinkConstraints, and Property2D by name + //Add/remove any type in the dictionary below that you want (or not) a specific comparison method for. + + private void SetupComparers() + { + AdapterComparers = new Dictionary + { + {typeof(Node), new BH.Engine.Structure.NodeDistanceComparer(3) }, //The 3 in here sets how many decimal places to look at for node merging. 3 decimal places gives mm precision + {typeof(ISectionProperty), new BHoMObjectNameOrToStringComparer() }, + {typeof(IMaterialFragment), new BHoMObjectNameComparer() }, + {typeof(LinkConstraint), new BHoMObjectNameComparer() }, + {typeof(ISurfaceProperty), new BHoMObjectNameComparer() }, + {typeof(ICase), new BHoMObjectNameComparer() }, + }; + } + + /***************************************************/ + } +} \ No newline at end of file diff --git a/SAP2000_Adapter/Types/SetupDependencies.cs b/SAP2000_Adapter/Types/SetupDependencies.cs new file mode 100644 index 0000000..0362e2f --- /dev/null +++ b/SAP2000_Adapter/Types/SetupDependencies.cs @@ -0,0 +1,34 @@ +using BH.oM.Structure.MaterialFragments; +using BH.oM.Structure.Elements; +using BH.oM.Structure.Constraints; +using BH.oM.Structure.SectionProperties; +using BH.oM.Structure.SurfaceProperties; +using BH.oM.Structure.Loads; +using System; +using System.Collections.Generic; + +namespace BH.Adapter.SAP2000 +{ + public partial class SAP2000Adapter + { + /***************************************************/ + /**** Protected Methods ****/ + /***************************************************/ + + protected void SetupDependencies() + { + DependencyTypes = new Dictionary> + { + {typeof(Bar), new List { typeof(ISectionProperty), typeof(Node) } }, + {typeof(ISectionProperty), new List { typeof(IMaterialFragment) } }, + {typeof(Panel), new List { typeof(ISurfaceProperty) } }, + {typeof(ISurfaceProperty), new List { typeof(IMaterialFragment) } }, + {typeof(RigidLink), new List { typeof(LinkConstraint), typeof(Node) } }, + {typeof(ILoad), new List {typeof(Loadcase) } }, + {typeof(LoadCombination), new List {typeof(Loadcase) } } + }; + } + + /***************************************************/ + } +} diff --git a/SAP2000_Adapter/Update/UpdateObjects.cs b/SAP2000_Adapter/Update/UpdateObjects.cs deleted file mode 100644 index 61959c1..0000000 --- a/SAP2000_Adapter/Update/UpdateObjects.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections.Generic; - -namespace BH.Adapter.SAP2000 -{ - public partial class SAP2000Adapter - { - /***************************************************/ - /**** Adapter overload method ****/ - /***************************************************/ - - //Method being called for any object already existing in the model in terms of comparers is found. - //Default implementation first deletes these objects, then creates new ones, if not applicable for the software, override this method - - protected override bool UpdateObjects(IEnumerable objects) - { - return base.UpdateObjects(objects); - } - - /***************************************************/ - } -} diff --git a/SAP2000_Engine/AdapterId.cs b/SAP2000_Engine/AdapterIdName.cs similarity index 85% rename from SAP2000_Engine/AdapterId.cs rename to SAP2000_Engine/AdapterIdName.cs index c2e03f0..55cdf9e 100644 --- a/SAP2000_Engine/AdapterId.cs +++ b/SAP2000_Engine/AdapterIdName.cs @@ -6,7 +6,7 @@ public partial class Convert /**** Public Strings ****/ /***************************************************/ - public const string AdapterId = "SAP2000_id"; + public const string AdapterIdName = "SAP2000_id"; /***************************************************/ } diff --git a/SAP2000_Engine/SAP2000_Engine.csproj b/SAP2000_Engine/SAP2000_Engine.csproj index 370e925..259ff1e 100644 --- a/SAP2000_Engine/SAP2000_Engine.csproj +++ b/SAP2000_Engine/SAP2000_Engine.csproj @@ -134,7 +134,7 @@ - + diff --git a/SAP2000_oM/Config/Config.cs b/SAP2000_oM/Config/Config.cs index 7c893a7..c5b2e76 100644 --- a/SAP2000_oM/Config/Config.cs +++ b/SAP2000_oM/Config/Config.cs @@ -1,9 +1,13 @@ -using BH.oM.Base; +using BH.oM.Adapter; +using BH.oM.Base; using System.ComponentModel; namespace BH.oM.Adapters.SAP2000 { - public class SAP2000Config : BHoMObject + [Description("This Config can be specified in the `ActionConfig` input of any Adapter Action (e.g. Push).")] + // Note: this will get passed within any CRUD method (see their signature). + // In order to access its properties, you will need to cast it to `SAP2000ActionConfig`. + public class SAP2000ActionConfig : ActionConfig { /***************************************************/ /**** Public Properties ****/ diff --git a/SAP2000_oM/SAP2000_oM.csproj b/SAP2000_oM/SAP2000_oM.csproj index aa6cae0..d50f865 100644 --- a/SAP2000_oM/SAP2000_oM.csproj +++ b/SAP2000_oM/SAP2000_oM.csproj @@ -31,6 +31,9 @@ 4 + + ..\..\BHoM_Adapter\Build\Adapter_oM.dll + ..\..\BHoM\Build\BHoM.dll False