Skip to content

Commit

Permalink
Remove "Lusas_id" references and replace with AdapterIdName object in…
Browse files Browse the repository at this point in the history
… Lusas_Engine
  • Loading branch information
peterjamesnugent committed Mar 9, 2020
1 parent 17781a2 commit 0dac890
Show file tree
Hide file tree
Showing 26 changed files with 55 additions and 25 deletions.
4 changes: 2 additions & 2 deletions Lusas_Adapter/CRUD/Read/Results/ReadResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private List<int> GetObjectIDs(IResultRequest request)
{
idsOut.Add(id);
}
else if (o is IBHoMObject && (o as IBHoMObject).CustomData.TryGetValue("Lusas_id", out idObj) && int.TryParse(idObj.ToString(), out id))
else if (o is IBHoMObject && (o as IBHoMObject).CustomData.TryGetValue(AdapterIdName, out idObj) && int.TryParse(idObj.ToString(), out id))
idsOut.Add(id);
}
return idsOut;
Expand Down Expand Up @@ -176,7 +176,7 @@ private List<int> GetLoadcaseIDs(IResultRequest request)
{
caseNums.Add(System.Convert.ToInt32(lCase.Item2.Number));
}
caseNums.Add(System.Convert.ToInt32((lComb as LoadCombination).CustomData["Lusas_id"]));
caseNums.Add(System.Convert.ToInt32((lComb as LoadCombination).CustomData[AdapterIdName]));
}
}

Expand Down
29 changes: 29 additions & 0 deletions Lusas_Engine/Convert/AdapterIdName.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2020, the respective contributors. All rights reserved.
*
* Each contributor holds copyright over their respective contributions.
* The project versioning (Git) records all such contribution source information.
*
*
* The BHoM is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3.0 of the License, or
* (at your option) any later version.
*
* The BHoM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

namespace BH.Engine.Lusas
{
public static partial class Convert
{
public const string AdapterIdName = "Lusas_id";
}
}
2 changes: 1 addition & 1 deletion Lusas_Engine/Convert/ToBHoM/Elements/ToBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Dictionary<string, MeshSettings1D> bhomMeshes

string adapterID = Engine.Lusas.Modify.RemovePrefix(lusasLine.getName(), "L");

bhomBar.CustomData["Lusas_id"] = adapterID;
bhomBar.CustomData[AdapterIdName] = adapterID;

return bhomBar;
}
Expand Down
2 changes: 1 addition & 1 deletion Lusas_Engine/Convert/ToBHoM/Elements/ToEdge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static Edge ToEdge(this IFLine lusasLine,

string adapterID = Engine.Lusas.Modify.RemovePrefix(lusasLine.getName(), "L");

bhomEdge.CustomData["Lusas_id"] = adapterID;
bhomEdge.CustomData[AdapterIdName] = adapterID;

return bhomEdge;
}
Expand Down
2 changes: 1 addition & 1 deletion Lusas_Engine/Convert/ToBHoM/Elements/ToNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static Node ToNode(this IFPoint lusasPoint,
bhomNode.Tags = tags;

string adapterID = Engine.Lusas.Modify.RemovePrefix(lusasPoint.getName(), "P");
bhomNode.CustomData["Lusas_id"] = adapterID;
bhomNode.CustomData[AdapterIdName] = adapterID;

return bhomNode;
}
Expand Down
2 changes: 1 addition & 1 deletion Lusas_Engine/Convert/ToBHoM/Elements/ToPanelPlanar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static Panel ToPanel(this IFSurface lusasSurface,
Panel bhomPanel = Structure.Create.Panel(surfaceEdges, dummyCurve);

bhomPanel.Tags = tags;
bhomPanel.CustomData["Lusas_id"] = lusasSurface.getName();
bhomPanel.CustomData[AdapterIdName] = lusasSurface.getName();

List<string> geometricAssignments = Lusas.Query.GetAttributeAssignments(lusasSurface, "Geometric");
List<string> materialAssignments = Lusas.Query.GetAttributeAssignments(lusasSurface, "Material");
Expand Down
2 changes: 1 addition & 1 deletion Lusas_Engine/Convert/ToBHoM/Loads/ToAreaTemperatureLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static AreaTemperatureLoad ToAreaTempratureLoad(
Lusas.Query.GetName(lusasTemperatureLoad));

int adapterID = Lusas.Query.GetAdapterID(lusasTemperatureLoad, 'l');
bhomAreaTemperatureLoad.CustomData["Lusas_id"] = adapterID;
bhomAreaTemperatureLoad.CustomData[AdapterIdName] = adapterID;

return bhomAreaTemperatureLoad;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static AreaUniformlyDistributedLoad ToAreaUniformlyDistributed(
}

int adapterID = Lusas.Query.GetAdapterID(lusasDistributed, 'l');
bhomSurfaceUniformlyDistributed.CustomData["Lusas_id"] = adapterID;
bhomSurfaceUniformlyDistributed.CustomData[AdapterIdName] = adapterID;

return bhomSurfaceUniformlyDistributed;
}
Expand Down
2 changes: 1 addition & 1 deletion Lusas_Engine/Convert/ToBHoM/Loads/ToBarDistributedLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static BarVaryingDistributedLoad ToBarDistributedLoad(IFLoading lusasBarD
Lusas.Query.GetName(lusasBarDistributedLoad));

int adapterID = Lusas.Query.GetAdapterID(lusasBarDistributedLoad, 'l');
bhomBarPointLoad.CustomData["Lusas_id"] = adapterID;
bhomBarPointLoad.CustomData[AdapterIdName] = adapterID;

return bhomBarPointLoad;
}
Expand Down
2 changes: 1 addition & 1 deletion Lusas_Engine/Convert/ToBHoM/Loads/ToBarPointLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static BarPointLoad ToBarPointLoad(IFLoading lusasBarPointLoad,
Lusas.Query.GetName(lusasBarPointLoad));

int adapterID = Lusas.Query.GetAdapterID(lusasBarPointLoad, 'l');
bhomBarPointLoad.CustomData["Lusas_id"] = adapterID;
bhomBarPointLoad.CustomData[AdapterIdName] = adapterID;

return bhomBarPointLoad;
}
Expand Down
2 changes: 1 addition & 1 deletion Lusas_Engine/Convert/ToBHoM/Loads/ToBarTemperatureLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static BarTemperatureLoad ToBarTemperatureLoad(
Lusas.Query.GetName(lusasTemperatureLoad));

int adapterID = Lusas.Query.GetAdapterID(lusasTemperatureLoad, 'l');
bhomBarTemperatureLoad.CustomData["Lusas_id"] = adapterID;
bhomBarTemperatureLoad.CustomData[AdapterIdName] = adapterID;
return bhomBarTemperatureLoad;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static BarUniformlyDistributedLoad ToBarUniformallyDistributed(IFLoading
}

int adapterID = Lusas.Query.GetAdapterID(lusasDistributed, 'l');
bhomBarUniformlyDistributed.CustomData["Lusas_id"] = adapterID;
bhomBarUniformlyDistributed.CustomData[AdapterIdName] = adapterID;

return bhomBarUniformlyDistributed;
}
Expand Down
2 changes: 1 addition & 1 deletion Lusas_Engine/Convert/ToBHoM/Loads/ToGravityLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static GravityLoad ToGravityLoad(IFLoading lusasGravityLoad,
bhomLoadcase, gravityVector, bhomObjects, Lusas.Query.GetName(lusasGravityLoad));

int adapterID = Lusas.Query.GetAdapterID(lusasGravityLoad, 'l');
bhomGravityLoad.CustomData["Lusas_id"] = adapterID;
bhomGravityLoad.CustomData[AdapterIdName] = adapterID;

return bhomGravityLoad;
}
Expand Down
2 changes: 1 addition & 1 deletion Lusas_Engine/Convert/ToBHoM/Loads/ToLoadCombination.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static LoadCombination ToLoadCombination(
};

int adapterID = Lusas.Query.GetAdapterID(lusasLoadCombination, 'c');
BHoMLoadCombination.CustomData["Lusas_id"] = adapterID;
BHoMLoadCombination.CustomData[AdapterIdName] = adapterID;

return BHoMLoadCombination;
}
Expand Down
2 changes: 1 addition & 1 deletion Lusas_Engine/Convert/ToBHoM/Loads/ToLoadcase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static Loadcase ToLoadcase(this IFLoadcase lusasLoadcase)

int adapterID = Lusas.Query.GetAdapterID(lusasLoadcase, 'c');

BHoMLoadcase.CustomData["Lusas_id"] = adapterID;
BHoMLoadcase.CustomData[AdapterIdName] = adapterID;

return BHoMLoadcase;
}
Expand Down
2 changes: 1 addition & 1 deletion Lusas_Engine/Convert/ToBHoM/Loads/ToPointDisplacement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static PointDisplacement ToPointDisplacement(IFLoading lusasPrescribedDis
Lusas.Query.GetName(lusasPrescribedDisplacement));

int adapterID = Lusas.Query.GetAdapterID(lusasPrescribedDisplacement, 'd');
bhomPointDisplacement.CustomData["Lusas_id"] = adapterID;
bhomPointDisplacement.CustomData[AdapterIdName] = adapterID;
// Needs to be a bit here that determines whether it is global or local - actually this cannot be done as the
//attribute is applied to a group, and within the group the axis could local or global

Expand Down
2 changes: 1 addition & 1 deletion Lusas_Engine/Convert/ToBHoM/Loads/ToPointLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static PointLoad ToPointLoad(
Lusas.Query.GetName(lusasPointLoad));

int adapterID = Lusas.Query.GetAdapterID(lusasPointLoad, 'l');
bhomPointLoad.CustomData["Lusas_id"] = adapterID;
bhomPointLoad.CustomData[AdapterIdName] = adapterID;

return bhomPointLoad;
}
Expand Down
2 changes: 1 addition & 1 deletion Lusas_Engine/Convert/ToBHoM/Properties/ToConstraint4DOF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static Constraint4DOF ToConstraint4DOF(this IFSupportStructural lusasAttr

int adapterID = Lusas.Query.GetAdapterID(lusasAttribute, 'p');

bhomConstraint4DOF.CustomData["Lusas_id"] = adapterID;
bhomConstraint4DOF.CustomData[AdapterIdName] = adapterID;

return bhomConstraint4DOF;
}
Expand Down
2 changes: 1 addition & 1 deletion Lusas_Engine/Convert/ToBHoM/Properties/ToConstraint6DOF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static Constraint6DOF ToConstraint6DOF(this IFSupportStructural lusasAttr
attributeName, fixity, stiffness);

int adapterID = Lusas.Query.GetAdapterID(lusasAttribute, 'p');
bhomConstraint6DOF.CustomData["Lusas_id"] = adapterID;
bhomConstraint6DOF.CustomData[AdapterIdName] = adapterID;

return bhomConstraint6DOF;
}
Expand Down
2 changes: 1 addition & 1 deletion Lusas_Engine/Convert/ToBHoM/Properties/ToMaterial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static IMaterialFragment ToMaterial(this IFAttribute lusasAttribute)
}

int adapterID = Lusas.Query.GetAdapterID(lusasAttribute, 'M');
bhomMaterial.CustomData["Lusas_id"] = adapterID;
bhomMaterial.CustomData[AdapterIdName] = adapterID;

return bhomMaterial;
}
Expand Down
2 changes: 1 addition & 1 deletion Lusas_Engine/Convert/ToBHoM/Properties/ToMeshSettings1D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static MeshSettings1D ToMeshSettings1D(this IFAttribute lusasAttrbute)
};

int adapterID = Lusas.Query.GetAdapterID(lusasMeshLine, 'e');
bhomMeshSettings1D.CustomData["Lusas_id"] = adapterID;
bhomMeshSettings1D.CustomData[AdapterIdName] = adapterID;

return bhomMeshSettings1D;
}
Expand Down
2 changes: 1 addition & 1 deletion Lusas_Engine/Convert/ToBHoM/Properties/ToMeshSettings2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static MeshSettings2D ToMeshSettings2D(this IFAttribute lusasAttribute)
};

int adapterID = Lusas.Query.GetAdapterID(lusasAttribute, 'e');
bhomMeshSettings2D.CustomData["Lusas_id"] = adapterID;
bhomMeshSettings2D.CustomData[AdapterIdName] = adapterID;

return bhomMeshSettings2D;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static ISectionProperty ToSection(this IFAttribute lusasAttribute)

int adapterID = Lusas.Query.GetAdapterID(lusasAttribute, 'G');

bhomSection.CustomData["Lusas_id"] = adapterID;
bhomSection.CustomData[AdapterIdName] = adapterID;

return bhomSection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static ISurfaceProperty ToSurfaceProperty(this IFAttribute lusasAttribute

int adapterID = Lusas.Query.GetAdapterID(lusasAttribute, 'G');

bhomProperty2D.CustomData["Lusas_id"] = adapterID;
bhomProperty2D.CustomData[AdapterIdName] = adapterID;

return bhomProperty2D;
}
Expand Down
1 change: 1 addition & 0 deletions Lusas_Engine/Lusas_Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<Compile Include="Compute\SetSplitMethod.cs" />
<Compile Include="Compute\CreateReleaseString.cs" />
<Compile Include="Convert\Double.cs" />
<Compile Include="Convert\AdapterIdName.cs" />
<Compile Include="Convert\ToBHoM\Properties\ToProfile.cs" />
<Compile Include="Create\MeshSettings1D.cs" />
<Compile Include="Query\CheckIllegalCharacters.cs" />
Expand Down
2 changes: 1 addition & 1 deletion Lusas_Engine/Query/GetObjectIDs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static List<int> GetObjectIDs(IList ids)
{
idsOut.Add(id);
}
else if (o is IBHoMObject && (o as IBHoMObject).CustomData.TryGetValue("Lusas_id", out idObj) && int.TryParse(idObj.ToString(), out id))
else if (o is IBHoMObject && (o as IBHoMObject).CustomData.TryGetValue(BH.Engine.Lusas.Convert.AdapterIdName, out idObj) && int.TryParse(idObj.ToString(), out id))
idsOut.Add(id);
}
return idsOut;
Expand Down

0 comments on commit 0dac890

Please sign in to comment.