Skip to content

Commit

Permalink
check if elements/nodes exist and return early if not
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristjan Nielsen committed Oct 6, 2023
1 parent 9867c53 commit c4fa90d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions GsaGH/Components/6_Display/Contour1dResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,10 @@ var footfallType

var elems = new ConcurrentDictionary<int, Element>(result.Model.Model.Elements(elementlist));
var nodes = new ConcurrentDictionary<int, Node>(result.Model.Model.Nodes());
if (elems.Count == 0) {
this.AddRuntimeError($"Model contains no results for elements in list '{elementlist}'");
return;
};

ConcurrentDictionary<int, ConcurrentDictionary<int, GsaResultQuantity>> xyzResults
= res.XyzResults;
Expand Down
4 changes: 4 additions & 0 deletions GsaGH/Components/6_Display/Contour2dResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,10 @@ var footfallType

ReadOnlyDictionary<int, Element> elems = result.Model.Model.Elements(elementlist);
ReadOnlyDictionary<int, Node> nodes = result.Model.Model.Nodes();
if (elems.Count == 0) {
this.AddRuntimeError($"Model contains no results for elements in list '{elementlist}'");
return;
};

ConcurrentDictionary<int, ConcurrentDictionary<int, GsaResultQuantity>> xyzResults
= _isShear ? resShear.XyzResults : res.XyzResults;
Expand Down
4 changes: 4 additions & 0 deletions GsaGH/Components/6_Display/ContourNodeResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,10 @@ var footfallType
}

ReadOnlyDictionary<int, Node> nodes = result.Model.Model.Nodes(nodeList);
if (nodes.Count == 0) {
this.AddRuntimeError($"Model contains no results for nodes in list '{nodeList}'");
return;
}

ConcurrentDictionary<int, ConcurrentDictionary<int, GsaResultQuantity>> xyzResults
= res.XyzResults;
Expand Down

0 comments on commit c4fa90d

Please sign in to comment.