Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aligning with changes in BHoMAdapter Refactoring Level 04 #65

Merged
merged 14 commits into from
Jan 24, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<double, ICase> 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);
}
}
Expand All @@ -74,7 +74,7 @@ private bool CreateObject(ILoad bhLoad)
private bool CreateLoad(PointLoad bhLoad)
{
List<Node> 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 =
{
Expand All @@ -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);
}
Expand All @@ -104,7 +104,7 @@ private bool CreateLoad(PointLoad bhLoad)
private bool CreateLoad(BarUniformlyDistributedLoad bhLoad)
{
List<Bar> 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;
Expand All @@ -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++)
{
Expand All @@ -151,7 +151,7 @@ private bool CreateLoad(BarUniformlyDistributedLoad bhLoad)
private bool CreateLoad(AreaUniformlyDistributedLoad bhLoad)
{
List<IAreaElement> 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)
Expand All @@ -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++)
{
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ 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);
}

linkIds.Add(name);
}

bhLink.CustomData[AdapterId] = linkIds;
bhLink.CustomData[AdapterIdName] = linkIds;

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand All @@ -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())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Collections.Generic;
using System.Linq;
using BH.oM.Analytical;
using BH.oM.Adapter;

namespace BH.Adapter.SAP2000
{
Expand All @@ -20,7 +21,7 @@ public partial class SAP2000Adapter
/**** Adapter overload method ****/
/***************************************************/

protected override bool Create<T>(IEnumerable<T> objects)
protected override bool ICreate<T>(IEnumerable<T> objects, ActionConfig actionConfig = null)
{
bool success = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ private List<Bar> ReadBars(List<string> ids = null)
{

List<Bar> bhomBars = new List<Bar>();
Dictionary<string, Node> bhomNodes = ReadNodes().ToDictionary(x => x.CustomData[AdapterId].ToString());
Dictionary<string, ISectionProperty> bhomSections = ReadSectionProperties().ToDictionary(x => x.CustomData[AdapterId].ToString());
Dictionary<string, Node> bhomNodes = ReadNodes().ToDictionary(x => x.CustomData[AdapterIdName].ToString());
Dictionary<string, ISectionProperty> bhomSections = ReadSectionProperties().ToDictionary(x => x.CustomData[AdapterIdName].ToString());

int nameCount = 0;
string[] names = { };
Expand All @@ -33,7 +33,7 @@ private List<Bar> ReadBars(List<string> 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);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private List<Loadcase> ReadLoadcase(List<string> 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);
}
}
Expand All @@ -53,7 +53,7 @@ private List<LoadCombination> ReadLoadCombination(List<string> ids = null)
{
List<LoadCombination> combinations = new List<LoadCombination>();

Dictionary<string, Loadcase> bhomCases = ReadLoadcase().ToDictionary(x => x.CustomData[AdapterId].ToString());
Dictionary<string, Loadcase> bhomCases = ReadLoadcase().ToDictionary(x => x.CustomData[AdapterIdName].ToString());

int count = 0;
string[] names = null;
Expand All @@ -78,7 +78,7 @@ private List<LoadCombination> ReadLoadCombination(List<string> ids = null)
Name = names[i],
Number = i,
};
bhomCombo.CustomData[AdapterId] = names[i];
bhomCombo.CustomData[AdapterIdName] = names[i];
if (caseCount > 0)
{
List<ICase> comboCases = new List<ICase>();
Expand Down Expand Up @@ -124,7 +124,7 @@ private List<ILoad> ReadPointLoad(List<string> ids = null)
List<ILoad> loads = new List<ILoad>();

Dictionary<string, Loadcase> bhomCases = ReadLoadcase().ToDictionary(x => x.Name.ToString());
Dictionary<string, Node> bhomNodes = ReadNodes().ToDictionary(x => x.CustomData[AdapterId].ToString());
Dictionary<string, Node> bhomNodes = ReadNodes().ToDictionary(x => x.CustomData[AdapterIdName].ToString());

int count = 0;
string[] nodeNames = null;
Expand Down Expand Up @@ -166,7 +166,7 @@ private List<ILoad> ReadBarLoad(List<string> ids = null)
List<ILoad> loads = new List<ILoad>();

Dictionary<string, Loadcase> bhomCases = ReadLoadcase().ToDictionary(x => x.Name.ToString());
Dictionary<string, Bar> bhomBars = ReadBars().ToDictionary(x => x.CustomData[AdapterId].ToString());
Dictionary<string, Bar> bhomBars = ReadBars().ToDictionary(x => x.CustomData[AdapterIdName].ToString());

int count = 0;
string[] frameNames = null;
Expand Down Expand Up @@ -262,7 +262,7 @@ private List<ILoad> ReadAreaLoad(List<string> ids = null)
List<ILoad> loads = new List<ILoad>();

Dictionary<string, Loadcase> bhomCases = ReadLoadcase().ToDictionary(x => x.Name.ToString());
Dictionary<string, Panel> bhomPanels = ReadPanel().ToDictionary(x => x.CustomData[AdapterId].ToString());
Dictionary<string, Panel> bhomPanels = ReadPanel().ToDictionary(x => x.CustomData[AdapterIdName].ToString());

int count = 0;
string[] areaNames = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private List<IMaterialFragment> ReadMaterial(List<string> ids = null)
break;
}

m.CustomData.Add(AdapterId, materialName);
m.CustomData.Add(AdapterIdName, materialName);

materialList.Add(m);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private List<Node> ReadNodes(List<string> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ private List<Panel> ReadPanel(List<string> ids = null)
{
List<Panel> bhomPanels = new List<Panel>();

Dictionary<string, Node> bhomNodes = ReadNodes().ToDictionary(x => x.CustomData[AdapterId].ToString());
Dictionary<string, ISurfaceProperty> bhomProperties = ReadSurfaceProperty().ToDictionary(x => x.CustomData[AdapterId].ToString());
Dictionary<string, Node> bhomNodes = ReadNodes().ToDictionary(x => x.CustomData[AdapterIdName].ToString());
Dictionary<string, ISurfaceProperty> bhomProperties = ReadSurfaceProperty().ToDictionary(x => x.CustomData[AdapterIdName].ToString());

if (ids == null)
{
Expand Down Expand Up @@ -51,7 +51,7 @@ private List<Panel> ReadPanel(List<string> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class SAP2000Adapter
private List<RigidLink> ReadRigidLink(List<string> ids = null)
{
List<RigidLink> linkList = new List<RigidLink>();
Dictionary<string, Node> bhomNodes = ReadNodes().ToDictionary(x => x.CustomData[AdapterId].ToString());
Dictionary<string, Node> 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;
Expand Down
Loading