Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion MidasCivil_Adapter/CRUD/Read/Results/NodeResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,23 @@ public IEnumerable<IResult> ReadResults(NodeResultRequest request, ActionConfig
case "9.5.5.nx":
List<string> loadCasesNX = Task.Run(() => AppendCaseTypes(request)).Result;
if (loadCasesNX != null)
results = Task.Run(() => ReadResult(request.ResultType.ToString(), objectIds, loadCasesNX)).Result.ToList();
{
results = Task.Run(() => ReadResult(request.ResultType.ToString() + request.Axis.ToString(), objectIds, loadCasesNX)).Result.ToList();

if (request.Axis == LoadAxis.Local)
{
List<IResult> resultsGlobal = Task.Run(() => ReadResult(request.ResultType.ToString() + LoadAxis.Global.ToString(), objectIds, loadCasesNX)).Result.ToList();
foreach (IResult resultLocal in results)
{
int globalIndex = resultsGlobal.FindIndex(x => ((NodeResult)x).ObjectId.CompareTo(((NodeResult)resultLocal).ObjectId) == 0);
if (globalIndex >= 0)
{
resultsGlobal[globalIndex] = resultLocal;
}
}
results = resultsGlobal;
}
}
break;
default:
List<string> loadCases = GetLoadcaseIDs(request);
Expand Down
7 changes: 6 additions & 1 deletion MidasCivil_Adapter/PrivateHelpers/AppendCaseTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,21 @@
List<string> filteredNames = new List<string>();

object parsedResponse = Engine.Serialiser.Convert.FromJson(response);
Dictionary<string, object> caseInfo = parsedResponse.PropertyValue("CustomData").PropertyValue(location).PropertyValue("CustomData") as Dictionary<string, object>;

Check warning on line 77 in MidasCivil_Adapter/PrivateHelpers/AppendCaseTypes.cs

View check run for this annotation

BHoMBot-CI / code-compliance

MidasCivil_Adapter/PrivateHelpers/AppendCaseTypes.cs#L77

The use of CustomData within the code is discouraged except in circumstances where volatile data is being used. - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsUsingCustomData

if (caseInfo != null)
{
foreach (var item in caseInfo)
{
Dictionary<string, object> combData = item.Value.PropertyValue("CustomData") as Dictionary<string, object>;

Check warning on line 83 in MidasCivil_Adapter/PrivateHelpers/AppendCaseTypes.cs

View check run for this annotation

BHoMBot-CI / code-compliance

MidasCivil_Adapter/PrivateHelpers/AppendCaseTypes.cs#L83

The use of CustomData within the code is discouraged except in circumstances where volatile data is being used. - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsUsingCustomData
string name = combData["NAME"].ToString();
if (filters.Contains(name))
filteredNames.Add(name + ending);
{
if (combData.ContainsKey("bCB") && combData["bCB"].ToString() == "True" && ending == "(CB)") // Checks whether the LoadCombination represents an envelope
filteredNames.AddRange(new List<string> { name + "(CB:all)", name + "(CB:max)", name + "(CB:min)" });
else
filteredNames.Add(name + ending);
}
}

Check warning on line 92 in MidasCivil_Adapter/PrivateHelpers/AppendCaseTypes.cs

View check run for this annotation

BHoMBot-CI / code-compliance

MidasCivil_Adapter/PrivateHelpers/AppendCaseTypes.cs#L81-L92

The use of CustomData within the code is discouraged except in circumstances where volatile data is being used. - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsUsingCustomData
}

Check warning on line 93 in MidasCivil_Adapter/PrivateHelpers/AppendCaseTypes.cs

View check run for this annotation

BHoMBot-CI / code-compliance

MidasCivil_Adapter/PrivateHelpers/AppendCaseTypes.cs#L79-L93

The use of CustomData within the code is discouraged except in circumstances where volatile data is being used. - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsUsingCustomData
return filteredNames;
Expand Down
53 changes: 52 additions & 1 deletion MidasCivil_Adapter/PrivateHelpers/ReadResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,27 @@
switch (resultType)
{
case "NodeReaction":
case "NodeReactionGlobal":
tableName = "\"TABLE_NAME\": \"Reaction(Global)\", ";
tableType = "\"TABLE_TYPE\": \"REACTIONG\", ";
components = "\"COMPONENTS\": [\"Node\", \"Load\", \"FX\", \"FY\", \"FZ\", \"MX\", \"MY\", \"MZ\"], ";
break;
case "NodeDisplacement":
case "NodeDisplacementGlobal":
tableName = "\"TABLE_NAME\": \"Displacements(Global)\", ";
tableType = "\"TABLE_TYPE\": \"DISPLACEMENTG\", ";
components = "\"COMPONENTS\": [\"Node\", \"Load\", \"DX\", \"DY\", \"DZ\", \"RX\", \"RY\", \"RZ\"], ";
break;
case "NodeReactionLocal":
tableName = "\"TABLE_NAME\": \"Reaction(Local)\", ";
tableType = "\"TABLE_TYPE\": \"REACTIONL\", ";
components = "\"COMPONENTS\": [\"Node\", \"Load\", \"FX\", \"FY\", \"FZ\", \"MX\", \"MY\", \"MZ\"], ";
break;
case "NodeDisplacementLocal":
tableName = "\"TABLE_NAME\": \"Displacements(Local)\", ";
tableType = "\"TABLE_TYPE\": \"DISPLACEMENTL\", ";
components = "\"COMPONENTS\": [\"Node\", \"Load\", \"DX\", \"DY\", \"DZ\", \"RX\", \"RY\", \"RZ\"], ";
break;
case "BarForce":
tableName = "\"TABLE_NAME\": \"BeamForce\", ";
tableType = "\"TABLE_TYPE\": \"BEAMFORCE\", ";
Expand Down Expand Up @@ -124,18 +136,19 @@

List<List<object>> resultItems= new List<List<object>>();
object data = new object();
switch (resultType)
{
case "NodeReaction":
case "NodeReactionGlobal":
switch (m_midasCivilVersion)
{
case "9.5.0.nx":
data = parsedJson.PropertyValue("CustomData")?.PropertyValue("Reaction(Global)")?.PropertyValue("DATA");
break;
default:
data = parsedJson.PropertyValue("CustomData")?.PropertyValue("ReactionGlobal")?.PropertyValue("DATA");
break;
}

Check warning on line 151 in MidasCivil_Adapter/PrivateHelpers/ReadResult.cs

View check run for this annotation

BHoMBot-CI / code-compliance

MidasCivil_Adapter/PrivateHelpers/ReadResult.cs#L143-L151

The use of CustomData within the code is discouraged except in circumstances where volatile data is being used. - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsUsingCustomData
resultItems = data as List<List<object>>;
if (resultItems.IsNullOrEmpty())
Engine.Base.Compute.RecordError($"No NodeReaction could be found for the selected Node/Nodes.");
Expand All @@ -144,19 +157,57 @@
results.Add(Adapters.MidasCivil.Convert.ToNodeReaction(item));
break;
case "NodeDisplacement":
case "NodeDisplacementGlobal":
switch (m_midasCivilVersion)
{
case "9.5.0.nx":
data = parsedJson.PropertyValue("CustomData")?.PropertyValue("Displacements(Global)")?.PropertyValue("DATA");
break;
default:
data = parsedJson.PropertyValue("CustomData")?.PropertyValue("DisplacementsGlobal")?.PropertyValue("DATA");
break;
}

Check warning on line 169 in MidasCivil_Adapter/PrivateHelpers/ReadResult.cs

View check run for this annotation

BHoMBot-CI / code-compliance

MidasCivil_Adapter/PrivateHelpers/ReadResult.cs#L161-L169

The use of CustomData within the code is discouraged except in circumstances where volatile data is being used. - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsUsingCustomData
resultItems = data as List<List<object>>;
foreach (List<object> item in resultItems)
if (resultItems.IsNullOrEmpty())
Engine.Base.Compute.RecordError($"No NodeDisplacement could be found for the selected Node/Nodes.");
else
foreach (List<object> item in resultItems)
results.Add(Adapters.MidasCivil.Convert.ToNodeDisplacement(item));
break;
case "NodeReactionLocal":
switch (m_midasCivilVersion)
{
case "9.5.0.nx":
data = parsedJson.PropertyValue("CustomData")?.PropertyValue("Reaction(Local)")?.PropertyValue("DATA");
break;
default:
data = parsedJson.PropertyValue("CustomData")?.PropertyValue("ReactionLocal")?.PropertyValue("DATA");
break;
}

Check warning on line 186 in MidasCivil_Adapter/PrivateHelpers/ReadResult.cs

View check run for this annotation

BHoMBot-CI / code-compliance

MidasCivil_Adapter/PrivateHelpers/ReadResult.cs#L178-L186

The use of CustomData within the code is discouraged except in circumstances where volatile data is being used. - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsUsingCustomData
resultItems = data as List<List<object>>;
if (resultItems.IsNullOrEmpty())
Engine.Base.Compute.RecordError($"No NodeReaction could be found for the selected Node/Nodes.");
else
foreach (List<object> item in resultItems)
results.Add(Adapters.MidasCivil.Convert.ToNodeReaction(item));
break;
case "NodeDisplacementLocal":
switch (m_midasCivilVersion)
{
case "9.5.0.nx":
data = parsedJson.PropertyValue("CustomData")?.PropertyValue("Displacements(Local)")?.PropertyValue("DATA");
break;
default:
data = parsedJson.PropertyValue("CustomData")?.PropertyValue("DisplacementsLocal")?.PropertyValue("DATA");
break;
}

Check warning on line 203 in MidasCivil_Adapter/PrivateHelpers/ReadResult.cs

View check run for this annotation

BHoMBot-CI / code-compliance

MidasCivil_Adapter/PrivateHelpers/ReadResult.cs#L195-L203

The use of CustomData within the code is discouraged except in circumstances where volatile data is being used. - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsUsingCustomData
resultItems = data as List<List<object>>;
if (resultItems.IsNullOrEmpty())
Engine.Base.Compute.RecordError($"No NodeDisplacement could be found for the selected Node/Nodes.");
else
foreach (List<object> item in resultItems)
results.Add(Adapters.MidasCivil.Convert.ToNodeDisplacement(item));
break;
case "BarForce":
data = parsedJson.PropertyValue("CustomData")?.PropertyValue("BeamForce")?.PropertyValue("DATA");
resultItems = data as List<List<object>>;
Expand All @@ -170,29 +221,29 @@
results.Add(Convert.ToBarStress(item));
break;
case "Forces":
switch (m_midasCivilVersion)
{
case "9.5.0.nx":
data = parsedJson.PropertyValue("CustomData")?.PropertyValue("PlateForce(UnitLength:Local)")?.PropertyValue("DATA");
break;
default:
data = parsedJson.PropertyValue("CustomData")?.PropertyValue("PlateForceUnitLengthLocal")?.PropertyValue("DATA");
break;
}

Check warning on line 232 in MidasCivil_Adapter/PrivateHelpers/ReadResult.cs

View check run for this annotation

BHoMBot-CI / code-compliance

MidasCivil_Adapter/PrivateHelpers/ReadResult.cs#L224-L232

The use of CustomData within the code is discouraged except in circumstances where volatile data is being used. - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsUsingCustomData
resultItems = data as List<List<object>>;
foreach (List<object> item in resultItems)
results.Add(Convert.ToMeshForce(item));
break;
case "Stresses":
switch (m_midasCivilVersion)
{
case "9.5.0.nx":
data = parsedJson.PropertyValue("CustomData")?.PropertyValue("PlateStress(Local)")?.PropertyValue("DATA");
break;
default:
data = parsedJson.PropertyValue("CustomData")?.PropertyValue("PlateStressLocal")?.PropertyValue("DATA");
break;
}

Check warning on line 246 in MidasCivil_Adapter/PrivateHelpers/ReadResult.cs

View check run for this annotation

BHoMBot-CI / code-compliance

MidasCivil_Adapter/PrivateHelpers/ReadResult.cs#L238-L246

The use of CustomData within the code is discouraged except in circumstances where volatile data is being used. - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsUsingCustomData
resultItems = data as List<List<object>>;
foreach (List<object> item in resultItems)
{
Expand All @@ -202,15 +253,15 @@
}
break;
case "VonMises":
switch (m_midasCivilVersion)
{
case "9.5.0.nx":
data = parsedJson.PropertyValue("CustomData")?.PropertyValue("PlateStress(Local)")?.PropertyValue("DATA");
break;
default:
data = parsedJson.PropertyValue("CustomData")?.PropertyValue("PlateStressLocal")?.PropertyValue("DATA");
break;
}

Check warning on line 264 in MidasCivil_Adapter/PrivateHelpers/ReadResult.cs

View check run for this annotation

BHoMBot-CI / code-compliance

MidasCivil_Adapter/PrivateHelpers/ReadResult.cs#L256-L264

The use of CustomData within the code is discouraged except in circumstances where volatile data is being used. - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsUsingCustomData
resultItems = data as List<List<object>>;
foreach (List<object> item in resultItems)
{
Expand Down