From 5f011da602a60afe28cd46ee90ecaf68e6cd5ed1 Mon Sep 17 00:00:00 2001 From: Peter Nugent Date: Tue, 12 Sep 2023 22:18:35 +0100 Subject: [PATCH] Add new method to deal with BarRelease for Lusas200 using preprocessor directives --- .../Convert/ToBHoM/Elements/ToBar.cs | 42 ++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/Lusas_Adapter/Convert/ToBHoM/Elements/ToBar.cs b/Lusas_Adapter/Convert/ToBHoM/Elements/ToBar.cs index f15dbab5..ed827fd7 100644 --- a/Lusas_Adapter/Convert/ToBHoM/Elements/ToBar.cs +++ b/Lusas_Adapter/Convert/ToBHoM/Elements/ToBar.cs @@ -162,13 +162,23 @@ public static Tuple GetMeshProperties(IFLi private static BarRelease GetBarRelease(IFMeshLine lusasLineMesh) { + Constraint6DOF startConstraint = null; + Constraint6DOF endConstraint = null; + +#if Debug200 || Release200 + + startConstraint = GetConstraint(lusasLineMesh, "Start"); + endConstraint = GetConstraint(lusasLineMesh, "End"); +#else object[] startReleases = lusasLineMesh.getValue("start"); object[] endReleases = lusasLineMesh.getValue("end"); - List startReleaseType = GetConstraints(startReleases); - List endReleaseType = GetConstraints(endReleases); - Constraint6DOF startConstraint = SetConstraint(startReleaseType); - Constraint6DOF endConstraint = SetConstraint(endReleaseType); + List startReleaseType = GetReleases(startReleases); + List endReleaseType = GetReleases(endReleases); + + startConstraint = SetConstraint(startReleaseType); + endConstraint = SetConstraint(endReleaseType); +#endif BarRelease barRelease = new BarRelease { @@ -198,7 +208,7 @@ private static Constraint6DOF SetConstraint(List releaseType) /***************************************************/ - private static List GetConstraints(object[] releases) + private static List GetReleases(object[] releases) { List releaseType = new List(); @@ -291,6 +301,28 @@ private static BarFEAType GetFEAType(object type) /***************************************************/ + // This method is required for Lusas v200 because the default method no longer works due to API changes, so each DOF must be requested individually + private static Constraint6DOF GetConstraint(IFMeshLine mesh, string location) + { + List freedoms = new List() { "U", "V", "W", "THX", "THY", "THZ" }; + List dofs = new List(); + + foreach(string freedom in freedoms) + { + if (mesh.getEndRelease(location, freedom) == 0) + dofs.Add(DOFType.Free); + else + dofs.Add(DOFType.Fixed); + } + + Constraint6DOF constraint = SetConstraint(dofs); + + return constraint; + } + + + /***************************************************/ + } }