Skip to content

Commit

Permalink
Merge branch 'release/10.2.9' into task/GSAGH-474-Preserve-data-tree-…
Browse files Browse the repository at this point in the history
…structure-in-case-of-null-results-or-errors
  • Loading branch information
tlmnrnhrdt committed May 10, 2024
2 parents 10c82fd + e343fd0 commit 8cd7fd4
Show file tree
Hide file tree
Showing 65 changed files with 1,453 additions and 501 deletions.
Binary file modified ExampleFiles/Components/LoadsFromReferenceObjects.gh
Binary file not shown.
38 changes: 15 additions & 23 deletions GsaGH/Components/0_Model/GetModelLoads.cs
@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.Linq;
using Grasshopper.Kernel;
using GsaAPI;
using GsaGH.Helpers.GH;
using GsaGH.Parameters;
using GsaGH.Properties;
Expand Down Expand Up @@ -92,29 +92,21 @@ public class GetModelLoads : GH_OasysDropDownComponent {
GsaModelGoo modelGoo = null;
da.GetData(0, ref modelGoo);

GsaAPI.Model model = modelGoo.Value.Model;
ReadOnlyDictionary<int, GsaAPI.LoadCase> loadCases = model.LoadCases();
List<GsaLoadCaseGoo> cases = GsaLoadFactory.CreateLoadCasesFromApi(loadCases);
List<GsaLoadGoo> gravity = GsaLoadFactory.CreateGravityLoadsFromApi(model.GravityLoads(), loadCases);
List<GsaLoadGoo> node = GsaLoadFactory.CreateNodeLoadsFromApi(model, loadCases);
List<GsaLoadGoo> beam = GsaLoadFactory.CreateBeamLoadsFromApi(model.BeamLoads(), loadCases);
List<GsaLoadGoo> beamThermal = GsaLoadFactory.CreateBeamThermalLoadsFromApi(model.BeamThermalLoads(), loadCases);
List<GsaLoadGoo> face = GsaLoadFactory.CreateFaceLoadsFromApi(model.FaceLoads(), loadCases);
List<GsaLoadGoo> faceThermal = GsaLoadFactory.CreateFaceThermalLoadsFromApi(model.FaceThermalLoads(), loadCases);

IReadOnlyDictionary<int, GsaAPI.GridSurface> srfDict = model.GridSurfaces();
IReadOnlyDictionary<int, GsaAPI.GridPlane> plnDict = model.GridPlanes();
IReadOnlyDictionary<int, GsaAPI.Axis> axDict = model.Axes();
List<GsaLoadGoo> point = GsaLoadFactory.CreateGridPointLoadsFromApi(
model.GridPointLoads(), srfDict, plnDict, axDict, loadCases, _lengthUnit);
List<GsaLoadGoo> line = GsaLoadFactory.CreateGridLineLoadsFromApi(
model.GridLineLoads(), srfDict, plnDict, axDict, loadCases, _lengthUnit);
List<GsaLoadGoo> area = GsaLoadFactory.CreateGridAreaLoadsFromApi(
model.GridAreaLoads(), srfDict, plnDict, axDict, loadCases, _lengthUnit);

Model model = modelGoo.Value.Model;
List<GsaLoadCaseGoo> cases = GsaLoadFactory.CreateLoadCasesFromApi(model);
List<GsaLoadGoo> gravity = GsaLoadFactory.CreateGravityLoadsFromApi(model);
List<GsaLoadGoo> node = GsaLoadFactory.CreateNodeLoadsFromApi(model);
List<GsaLoadGoo> beam = GsaLoadFactory.CreateBeamLoadsFromApi(model);
List<GsaLoadGoo> beamThermal = GsaLoadFactory.CreateBeamThermalLoadsFromApi(model);
List<GsaLoadGoo> face = GsaLoadFactory.CreateFaceLoadsFromApi(model);
List<GsaLoadGoo> faceThermal = GsaLoadFactory.CreateFaceThermalLoadsFromApi(model);
List<GsaLoadGoo> point = GsaLoadFactory.CreateGridPointLoadsFromApi(model, _lengthUnit);
List<GsaLoadGoo> line = GsaLoadFactory.CreateGridLineLoadsFromApi(model, _lengthUnit);
List<GsaLoadGoo> area = GsaLoadFactory.CreateGridAreaLoadsFromApi(model, _lengthUnit);

IReadOnlyDictionary<int, GridSurface> srfDict = model.GridSurfaces();
var gps = srfDict.Keys.Select(key
=> new GsaGridPlaneSurfaceGoo(GsaLoadFactory.CreateGridPlaneSurfaceFromApi(srfDict, plnDict, axDict, key,
_lengthUnit))).ToList();
=> new GsaGridPlaneSurfaceGoo(GsaLoadFactory.CreateGridPlaneSurfaceFromApi(model, key, _lengthUnit))).ToList();

da.SetDataList(0, cases);
da.SetDataList(1, gravity);
Expand Down
4 changes: 4 additions & 0 deletions GsaGH/Components/3_Loads/CreateBeamLoad.cs
Expand Up @@ -299,7 +299,11 @@ private enum FoldMode {

default:
if (GH_Convert.ToString(ghTyp.Value, out string beamList, GH_Conversion.Both)) {
beamLoad.ApiLoad.EntityType = GsaAPI.EntityType.Element;
beamLoad.ApiLoad.EntityList = beamList;
if (beamLoad.ApiLoad.EntityList != beamList && beamList.ToLower() != "all") {
beamLoad.ApiLoad.EntityList = $"\"{beamList}\"";
}
}
break;
}
Expand Down
7 changes: 5 additions & 2 deletions GsaGH/Components/3_Loads/CreateBeamThermalLoad.cs
Expand Up @@ -13,8 +13,8 @@
using OasysGH.Units;
using OasysGH.Units.Helpers;
using OasysUnits;
using OasysUnits.Units;
using EntityType = GsaGH.Parameters.EntityType;
using TemperatureUnit = OasysUnits.Units.TemperatureUnit;

namespace GsaGH.Components {
public class CreateBeamThermalLoad : GH_OasysDropDownComponent {
Expand Down Expand Up @@ -144,7 +144,6 @@ private enum FoldMode {

break;


case GsaElement1dGoo element1dGoo:
beamThermalLoad.RefObjectGuid = element1dGoo.Value.Guid;
beamThermalLoad.ApiLoad.EntityType = GsaAPI.EntityType.Element;
Expand Down Expand Up @@ -180,7 +179,11 @@ private enum FoldMode {

default:
if (GH_Convert.ToString(ghTyp.Value, out string beamList, GH_Conversion.Both)) {
beamThermalLoad.ApiLoad.EntityType = GsaAPI.EntityType.Element;
beamThermalLoad.ApiLoad.EntityList = beamList;
if (beamThermalLoad.ApiLoad.EntityList != beamList && beamList.ToLower() != "all") {
beamThermalLoad.ApiLoad.EntityList = $"\"{beamList}\"";
}
}
break;
}
Expand Down
97 changes: 50 additions & 47 deletions GsaGH/Components/3_Loads/CreateFaceLoad.cs
Expand Up @@ -256,59 +256,62 @@ private enum FoldMode {
var ghTyp = new GH_ObjectWrapper();
if (da.GetData(1, ref ghTyp)) {
switch (ghTyp.Value) {
case GsaListGoo value: {
if (value.Value.EntityType == EntityType.Element
|| value.Value.EntityType == EntityType.Member) {
faceLoad.ReferenceList = value.Value;
faceLoad.ReferenceType = ReferenceType.List;
} else {
this.AddRuntimeError(
"List must be of type Element or Member to apply to face loading");
return;
}
case GsaListGoo value:
if (value.Value.EntityType == EntityType.Element
|| value.Value.EntityType == EntityType.Member) {
faceLoad.ReferenceList = value.Value;
faceLoad.ReferenceType = ReferenceType.List;
} else {
this.AddRuntimeError(
"List must be of type Element or Member to apply to face loading");
return;
}

break;

case GsaElement2dGoo value:
faceLoad.RefObjectGuid = value.Value.Guid;
faceLoad.ApiLoad.EntityType = GsaAPI.EntityType.Element;
faceLoad.ReferenceType = ReferenceType.Element;
break;

case GsaMember2dGoo value:
faceLoad.RefObjectGuid = value.Value.Guid;
faceLoad.ApiLoad.EntityType = GsaAPI.EntityType.Member;
faceLoad.ReferenceType = ReferenceType.Member;
break;

break;
case GsaMaterialGoo value:
if (value.Value.Id != 0) {
this.AddRuntimeWarning(
"Reference Material must be a Custom Material");
return;
}
case GsaElement2dGoo value: {
faceLoad.RefObjectGuid = value.Value.Guid;
faceLoad.RefObjectGuid = value.Value.Guid;
faceLoad.ApiLoad.EntityType = GsaAPI.EntityType.Element;
faceLoad.ReferenceType = ReferenceType.Property;
this.AddRuntimeRemark(
"Load from Material reference created as Element load");
break;

case GsaProperty2dGoo value:
faceLoad.RefObjectGuid = value.Value.Guid;
faceLoad.ApiLoad.EntityType = GsaAPI.EntityType.Element;
faceLoad.ReferenceType = ReferenceType.Property;
this.AddRuntimeRemark(
"Load from 2D Property reference created as Element load");
break;

default:
if (GH_Convert.ToString(ghTyp.Value, out string elemList, GH_Conversion.Both)) {
faceLoad.ApiLoad.EntityType = GsaAPI.EntityType.Element;
faceLoad.ReferenceType = ReferenceType.Element;
break;
}
case GsaMember2dGoo value: {
faceLoad.RefObjectGuid = value.Value.Guid;
faceLoad.ApiLoad.EntityType = GsaAPI.EntityType.Member;
faceLoad.ReferenceType = ReferenceType.Member;
break;
}
case GsaMaterialGoo value: {
if (value.Value.Id != 0) {
this.AddRuntimeWarning(
"Reference Material must be a Custom Material");
return;
faceLoad.ApiLoad.EntityList = elemList;
if (faceLoad.ApiLoad.EntityList != elemList && elemList.ToLower() != "all") {
faceLoad.ApiLoad.EntityList = $"\"{elemList}\"";
}
faceLoad.RefObjectGuid = value.Value.Guid;
faceLoad.ApiLoad.EntityType = GsaAPI.EntityType.Element;
faceLoad.ReferenceType = ReferenceType.Property;
this.AddRuntimeRemark(
"Load from Material reference created as Element load");
break;
}
case GsaProperty2dGoo value: {
faceLoad.RefObjectGuid = value.Value.Guid;
faceLoad.ApiLoad.EntityType = GsaAPI.EntityType.Element;
faceLoad.ReferenceType = ReferenceType.Property;
this.AddRuntimeRemark(
"Load from 2D Property reference created as Element load");
break;
}
default: {
if (GH_Convert.ToString(ghTyp.Value, out string elemList, GH_Conversion.Both)) {
faceLoad.ApiLoad.EntityList = elemList;
}

break;
}
break;
}
}

Expand Down
99 changes: 51 additions & 48 deletions GsaGH/Components/3_Loads/CreateFaceThermalLoad.cs
Expand Up @@ -13,8 +13,8 @@
using OasysGH.Units;
using OasysGH.Units.Helpers;
using OasysUnits;
using OasysUnits.Units;
using EntityType = GsaGH.Parameters.EntityType;
using TemperatureUnit = OasysUnits.Units.TemperatureUnit;

namespace GsaGH.Components {
public class CreateFaceThermalLoad : GH_OasysDropDownComponent {
Expand Down Expand Up @@ -129,59 +129,62 @@ private enum FoldMode {
var ghTyp = new GH_ObjectWrapper();
if (da.GetData(1, ref ghTyp)) {
switch (ghTyp.Value) {
case GsaListGoo value: {
if (value.Value.EntityType == EntityType.Element
|| value.Value.EntityType == EntityType.Member) {
faceThermalLoad.ReferenceList = value.Value;
faceThermalLoad.ReferenceType = ReferenceType.List;
} else {
this.AddRuntimeError(
"List must be of type Element or Member to apply to face loading");
return;
}
case GsaListGoo value:
if (value.Value.EntityType == EntityType.Element
|| value.Value.EntityType == EntityType.Member) {
faceThermalLoad.ReferenceList = value.Value;
faceThermalLoad.ReferenceType = ReferenceType.List;
} else {
this.AddRuntimeError(
"List must be of type Element or Member to apply to face loading");
return;
}

break;

case GsaElement2dGoo value:
faceThermalLoad.RefObjectGuid = value.Value.Guid;
faceThermalLoad.ApiLoad.EntityType = GsaAPI.EntityType.Element;
faceThermalLoad.ReferenceType = ReferenceType.Element;
break;

case GsaMember2dGoo value:
faceThermalLoad.RefObjectGuid = value.Value.Guid;
faceThermalLoad.ApiLoad.EntityType = GsaAPI.EntityType.Member;
faceThermalLoad.ReferenceType = ReferenceType.Member;
break;

break;
case GsaMaterialGoo value:
if (value.Value.Id != 0) {
this.AddRuntimeWarning(
"Reference Material must be a Custom Material");
return;
}
case GsaElement2dGoo value: {
faceThermalLoad.RefObjectGuid = value.Value.Guid;
faceThermalLoad.RefObjectGuid = value.Value.Guid;
faceThermalLoad.ApiLoad.EntityType = GsaAPI.EntityType.Element;
faceThermalLoad.ReferenceType = ReferenceType.Property;
this.AddRuntimeRemark(
"Load from Material reference created as Element load");
break;

case GsaProperty2dGoo value:
faceThermalLoad.RefObjectGuid = value.Value.Guid;
faceThermalLoad.ApiLoad.EntityType = GsaAPI.EntityType.Element;
faceThermalLoad.ReferenceType = ReferenceType.Property;
this.AddRuntimeRemark(
"Load from 2D Property reference created as Element load");
break;

default:
if (GH_Convert.ToString(ghTyp.Value, out string elemList, GH_Conversion.Both)) {
faceThermalLoad.ApiLoad.EntityType = GsaAPI.EntityType.Element;
faceThermalLoad.ReferenceType = ReferenceType.Element;
break;
}
case GsaMember2dGoo value: {
faceThermalLoad.RefObjectGuid = value.Value.Guid;
faceThermalLoad.ApiLoad.EntityType = GsaAPI.EntityType.Member;
faceThermalLoad.ReferenceType = ReferenceType.Member;
break;
}
case GsaMaterialGoo value: {
if (value.Value.Id != 0) {
this.AddRuntimeWarning(
"Reference Material must be a Custom Material");
return;
faceThermalLoad.ApiLoad.EntityList = elemList;
if (faceThermalLoad.ApiLoad.EntityList != elemList && elemList.ToLower() != "all") {
faceThermalLoad.ApiLoad.EntityList = $"\"{elemList}\"";
}
faceThermalLoad.RefObjectGuid = value.Value.Guid;
faceThermalLoad.ApiLoad.EntityType = GsaAPI.EntityType.Element;
faceThermalLoad.ReferenceType = ReferenceType.Property;
this.AddRuntimeRemark(
"Load from Material reference created as Element load");
break;
}
case GsaProperty2dGoo value: {
faceThermalLoad.RefObjectGuid = value.Value.Guid;
faceThermalLoad.ApiLoad.EntityType = GsaAPI.EntityType.Element;
faceThermalLoad.ReferenceType = ReferenceType.Property;
this.AddRuntimeRemark(
"Load from 2D Property reference created as Element load");
break;
}
default: {
if (GH_Convert.ToString(ghTyp.Value, out string elemList, GH_Conversion.Both)) {
faceThermalLoad.ApiLoad.EntityList = elemList;
}

break;
}
break;
}
}

Expand Down

0 comments on commit 8cd7fd4

Please sign in to comment.