Skip to content

Commit ab1ea55

Browse files
author
Fraser Greenroyd
authored
7.0 Deployment (#384)
2 parents 2be248d + 9b6fe8b commit ab1ea55

File tree

20 files changed

+180
-40
lines changed

20 files changed

+180
-40
lines changed

Lusas_Adapter/AdapterActions/Execute.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public bool RunCommand(NewModel command)
7171
d_LusasData.setVerticalDir("Z");
7272
m_LusasApplication.fileOpen("%PerMachineAppDataPlatform%\\config\\AfterNewModel");
7373
d_LusasData.setAnalysisCategory("3D");
74+
if (!double.IsNaN(m_mergeTolerance))
75+
d_LusasData.getOptions().setDouble("TOLMRG", m_mergeTolerance);
7476

7577
string fileName = $"{m_directory}\\sections.csv";
7678
File.Delete(fileName);
@@ -111,6 +113,8 @@ public bool RunCommand(Open command)
111113
{
112114
m_LusasApplication.openDatabase(command.FileName);
113115
d_LusasData = m_LusasApplication.getDatabase();
116+
if (!double.IsNaN(m_mergeTolerance))
117+
d_LusasData.getOptions().setDouble("TOLMRG", m_mergeTolerance);
114118
m_directory = command.FileName;
115119

116120
return true;

Lusas_Adapter/CRUD/Create/Loads/GravityLoad.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
using BH.oM.Structure.Loads;
2525
using BH.Engine.Adapter;
2626
using Lusas.LPI;
27+
using BH.oM.Geometry;
2728

2829
namespace BH.Adapter.Lusas
2930
{
@@ -47,15 +48,15 @@ private IFLoadingBody CreateGravityLoad(GravityLoad gravityLoad, IFGeometry[] lu
4748
{
4849
IFLoadingBody lusasGravityLoad;
4950
IFLoadcase assignedLoadcase = (IFLoadcase)d_LusasData.getLoadset(gravityLoad.Loadcase.AdapterId<int>(typeof(LusasId)));
50-
51+
5152
if (d_LusasData.existsAttribute("Loading", gravityLoad.Name))
5253
{
5354
lusasGravityLoad = (IFLoadingBody)d_LusasData.getAttributes("Loading", gravityLoad.Name);
5455
}
5556
else
5657
{
5758
lusasGravityLoad = d_LusasData.createLoadingBody(gravityLoad.Name);
58-
lusasGravityLoad.setBody(gravityLoad.GravityDirection.X, gravityLoad.GravityDirection.Y, gravityLoad.GravityDirection.Z);
59+
lusasGravityLoad.setBody(gravityLoad.GravityDirection.X * m_g, gravityLoad.GravityDirection.Y * m_g, gravityLoad.GravityDirection.Z * m_g);
5960
}
6061

6162
IFAssignment lusasAssignment = m_LusasApplication.assignment();

Lusas_Adapter/CRUD/Create/Loads/Loadcase.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,16 @@ private IFLoadcase CreateLoadcase(Loadcase loadcase)
4848
{
4949
IFLoadcase lusasLoadcase;
5050

51-
if (d_LusasData.existsLoadset(loadcase.Name))
51+
if (d_LusasData.existsLoadset(loadcase.Number))
5252
{
53-
lusasLoadcase = (IFLoadcase)d_LusasData.getLoadset(loadcase.Name);
53+
lusasLoadcase = (IFLoadcase)d_LusasData.getLoadset(loadcase.Number);
54+
if (lusasLoadcase.getName() != loadcase.Name)
55+
{
56+
Compute.RecordWarning(
57+
$"The loadcase {loadcase.Number} already exists but the number {lusasLoadcase.getID()} does not match with the loadcase being pushed: {loadcase.Name}, {loadcase.Number}. \n" +
58+
$"The loadcase {lusasLoadcase.getName()} has been used.");
59+
loadcase.Name = lusasLoadcase.getName();
60+
};
5461
}
5562
else
5663
{

Lusas_Adapter/CRUD/Create/Properties/GeometricLine.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ private bool CreateProfile(string name, ISectionProfile profile)
257257
int lusasType = 5;
258258
CreateLibrarySection(name, dimensionArray, lusasType);
259259

260+
Engine.Base.Compute.RecordWarning("Toe radius not supported in Lusas. 0 is used for toe radius");
261+
260262
return true;
261263
}
262264

Lusas_Adapter/CRUD/Read/Loads/GravityLoads.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ private List<ILoad> ReadGravityLoads(List<string> ids = null)
7272
foreach (IEnumerable<IFAssignment> groupedAssignment in groupedByLoadcases)
7373
{
7474
List<string> analysisName = new List<string> { lusasBodyForce.getAttributeType() };
75-
75+
7676
GravityLoad gravityLoad = Adapters.Lusas.Convert.ToGravityLoad(
77-
lusasBodyForce, groupedAssignment, nodes, bars, panels);
77+
lusasBodyForce, groupedAssignment, nodes, bars, panels, m_g);
7878
gravityLoad.Tags = new HashSet<string>(analysisName);
7979
gravityLoads.Add(gravityLoad);
8080
}

Lusas_Adapter/CRUD/Read/Results/ReadResults.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
using System.Linq;
3333
using BH.Engine.Adapters.Lusas;
3434
using BH.oM.Adapters.Lusas;
35+
using Lusas.LPI;
3536

3637
namespace BH.Adapter.Lusas
3738
{
@@ -179,6 +180,14 @@ private List<int> GetLoadcaseIDs(IResultRequest request)
179180
}
180181
}
181182

183+
else if (cases.Count == 0)
184+
{
185+
for (int i = 1; i <= d_LusasData.getLargestLoadsetID(); i++)
186+
{
187+
caseNums.Add(i);
188+
}
189+
}
190+
182191
else
183192
{
184193
List<int> idsOut = new List<int>();

Lusas_Adapter/Convert/ToBHoM/Loads/ToGravityLoad.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,17 @@ public static GravityLoad ToGravityLoad(IFLoading lusasGravityLoad,
4242
IEnumerable<IFAssignment> lusasAssignments,
4343
Dictionary<string, Node> nodes,
4444
Dictionary<string, Bar> bars,
45-
Dictionary<string, Panel> panels)
45+
Dictionary<string, Panel> panels,
46+
double g)
47+
4648
{
4749
IFLoadcase assignedLoadcase = (IFLoadcase)lusasAssignments.First().getAssignmentLoadset();
4850
Loadcase loadcase = ToLoadcase(assignedLoadcase);
4951
Vector gravityVector = new Vector
5052
{
51-
X = lusasGravityLoad.getValue("accX"),
52-
Y = lusasGravityLoad.getValue("accY"),
53-
Z = lusasGravityLoad.getValue("accZ")
53+
X = lusasGravityLoad.getValue("accX") / g,
54+
Y = lusasGravityLoad.getValue("accY") / g,
55+
Z = lusasGravityLoad.getValue("accZ") / g
5456
};
5557

5658
IEnumerable<BHoMObject> assignedObjects = GetGeometryAssignments(

Lusas_Adapter/Convert/ToBHoM/Properties/ToProfile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static IProfile ToProfile(IFAttribute lusasAttribute, int i)
8282
lusasAttribute.getValue("tw",i),
8383
lusasAttribute.getValue("tf",i),
8484
lusasAttribute.getValue("r",i),
85-
lusasAttribute.getValue("r",i)
85+
0
8686
);
8787
break;
8888
}

Lusas_Adapter/LusasAdapter.cs

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
using System.Collections.Generic;
3838
using System.Diagnostics;
3939
using System.IO;
40+
using BH.oM.Base.Attributes;
41+
using System.ComponentModel;
4042

4143
namespace BH.Adapter.Lusas
4244
{
@@ -56,15 +58,45 @@ public partial class LusasV17Adapter : BHoMAdapter
5658
/**** Constructors ****/
5759
/***************************************************/
5860
#if Debug18 || Release18
59-
public LusasV18Adapter(string filePath, LusasConfig lusasConfig = null, bool active = false)
61+
[PreviousVersion("7.0", "BH.Adapter.Lusas.LusasV18Adapter(System.String, BH.oM.Adapters.Lusas.LusasConfig, System.Boolean)")]
62+
[Description("Adapter to connect to a Lusas .mdl file.")]
63+
[Input("filePath", "Path to the Lusas .mdl file to be used.")]
64+
[Input("lusasSettings", "General settings that are applicable to all actions performed by this adapter, e.g. merge tolerance to be used.")]
65+
[Input("active", "Initiate the adapter by setting to True. Open a session of Lusas and close any dialogue boxes before setting to True.")]
66+
[Output("adapter", "Adapter for Lusas.")]
67+
public LusasV18Adapter(string filePath, LusasSettings lusasSettings = null, bool active = false)
6068
#elif Debug19 || Release19
61-
public LusasV19Adapter(string filePath, LusasConfig lusasConfig = null, bool active = false)
69+
[PreviousVersion("7.0", "BH.Adapter.Lusas.LusasV19Adapter(System.String, BH.oM.Adapters.Lusas.LusasConfig, System.Boolean)")]
70+
[Description("Adapter to connect to a Lusas .mdl file.")]
71+
[Input("filePath", "Path to the Lusas .mdl file to be used.")]
72+
[Input("lusasSettings", "General settings that are applicable to all actions performed by this adapter, e.g. merge tolerance to be used.")]
73+
[Input("active", "Initiate the adapter by setting to True. Open a session of Lusas and close any dialogue boxes before setting to True.")]
74+
[Output("adapter", "Adapter for Lusas.")]
75+
public LusasV19Adapter(string filePath, LusasSettings lusasSettings = null, bool active = false)
6276
#elif Debug191 || Release191
63-
public LusasV191Adapter(string filePath, LusasConfig lusasConfig = null, bool active = false)
77+
[PreviousVersion("7.0", "BH.Adapter.Lusas.LusasV191Adapter(System.String, BH.oM.Adapters.Lusas.LusasConfig, System.Boolean)")]
78+
[Description("Adapter to connect to a Lusas .mdl file.")]
79+
[Input("filePath", "Path to the Lusas .mdl file to be used.")]
80+
[Input("lusasSettings", "General settings that are applicable to all actions performed by this adapter, e.g. merge tolerance to be used.")]
81+
[Input("active", "Initiate the adapter by setting to True. Open a session of Lusas and close any dialogue boxes before setting to True.")]
82+
[Output("adapter", "Adapter for Lusas.")]
83+
public LusasV191Adapter(string filePath, LusasSettings lusasSettings = null, bool active = false)
6484
#elif Debug200 || Release200
65-
public LusasV200Adapter(string filePath, LusasConfig lusasConfig = null, bool active = false)
85+
[PreviousVersion("7.0", "BH.Adapter.Lusas.LusasV200Adapter(System.String, BH.oM.Adapters.Lusas.LusasConfig, System.Boolean)")]
86+
[Description("Adapter to connect to a Lusas .mdl file.")]
87+
[Input("filePath", "Path to the Lusas .mdl file to be used.")]
88+
[Input("lusasSettings", "General settings that are applicable to all actions performed by this adapter, e.g. merge tolerance to be used.")]
89+
[Input("active", "Initiate the adapter by setting to True. Open a session of Lusas and close any dialogue boxes before setting to True.")]
90+
[Output("adapter", "Adapter for Lusas.")]
91+
public LusasV200Adapter(string filePath, LusasSettings lusasSettings = null, bool active = false)
6692
#else
67-
public LusasV17Adapter(string filePath, LusasConfig lusasConfig = null, bool active = false)
93+
[PreviousVersion("7.0", "BH.Adapter.Lusas.LusasV17Adapter(System.String, BH.oM.Adapters.Lusas.LusasConfig, System.Boolean)")]
94+
[Description("Adapter to connect to a Lusas .mdl file.")]
95+
[Input("filePath", "Path to Lusas the .mdl file to be used.")]
96+
[Input("lusasSettings", "General settings that are applicable to all actions performed by this adapter, e.g. merge tolerance to be used.")]
97+
[Input("active", "Initiate the adapter by setting to True. Open a session of Lusas and close any dialogue boxes before setting to True.")]
98+
[Output("adapter", "Adapter for Lusas.")]
99+
public LusasV17Adapter(string filePath, LusasSettings lusasSettings = null, bool active = false)
68100
#endif
69101
{
70102
if (active)
@@ -131,6 +163,14 @@ public LusasV17Adapter(string filePath, LusasConfig lusasConfig = null, bool act
131163
{
132164
throw new Exception("An exception has been flagged by Lusas, it is likely the file is from a higher version of Lusas than the adapter being used.");
133165
}
166+
167+
if (lusasSettings != null && !double.IsNaN(lusasSettings.MergeTolerance))
168+
{
169+
m_mergeTolerance = lusasSettings.MergeTolerance;
170+
d_LusasData.getOptions().setDouble("TOLMRG", m_mergeTolerance);
171+
}
172+
173+
if (lusasSettings != null) { m_g = lusasSettings.StandardGravity; }
134174
}
135175
}
136176
}
@@ -151,10 +191,12 @@ public static bool IsApplicationRunning()
151191
//Add any comlink object as a private field here, example named:
152192

153193
private string m_directory;
194+
public double m_mergeTolerance = double.NaN;
195+
public double m_g = 9.80665;
154196
public LusasWinApp m_LusasApplication;
155197
public IFDatabase d_LusasData;
156198
private Dictionary<Type, Dictionary<int, HashSet<string>>> m_tags = new Dictionary<Type, Dictionary<int, HashSet<string>>>();
157-
public LusasConfig lusasConfig;
199+
public LusasSettings lusasSettings;
158200

159201

160202
/***************************************************/

Lusas_Adapter/Private Helpers/GetFeatureResults.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public partial class LusasV17Adapter
4545
private Dictionary<string, double> GetFeatureResults(List<string> components, Dictionary<string, IFResultsComponentSet> resultsSets, IFUnitSet unitSet, int id, string suffix, int resultType = 6)
4646
{
4747
Dictionary<string, double> featureResults = new Dictionary<string, double>();
48+
bool invalidResult = false;
4849
IFResultsComponentSet resultsSet = null;
4950

5051
foreach (string component in components)
@@ -99,12 +100,17 @@ private Dictionary<string, double> GetFeatureResults(List<string> components, Di
99100
if (!(resultsSet.isValidValue(featureResult)))
100101
{
101102
featureResult = 0;
102-
Engine.Base.Compute.RecordWarning($"{suffix}{id} {component} is an invalid result and will be set to zero");
103+
invalidResult = true;
103104
}
104105

105106
featureResults.Add(component, featureResult);
106107
}
107108

109+
if (invalidResult)
110+
{
111+
Engine.Base.Compute.RecordWarning($"Invalid results (i.e. where DOF is released) will be set to zero.");
112+
}
113+
108114
return featureResults;
109115
}
110116

0 commit comments

Comments
 (0)