public string SetGWACommand(int group = 0) { if (this.Value == null) { return(""); } var mesh = this.Value as Structural2DElement; var keyword = typeof(GSA2DElement).GetGSAKeyword(); var index = Initialiser.Cache.ResolveIndex(typeof(GSA2DElement).GetGSAKeyword(), mesh.ApplicationId); var propRef = 0; try { propRef = Initialiser.Cache.LookupIndex(typeof(GSA2DProperty).GetGSAKeyword(), mesh.PropertyRef).Value; } catch { } var ls = new List <string> { "SET", keyword + ":" + HelperClass.GenerateSID(mesh), index.ToString(), mesh.Name == null || mesh.Name == "" ? " " : mesh.Name, mesh.Colors == null || mesh.Colors.Count() < 1 ? "NO_RGB" : mesh.Colors[0].ArgbToHexColor().ToString(), mesh.Vertices.Count() / 3 == 3 ? "TRI3" : "QUAD4", propRef.ToString(), group.ToString() // Group }; var numVertices = mesh.Faces[0] + 3; var coor = new List <double>(); for (var i = 1; i < mesh.Faces.Count(); i++) { coor.AddRange(mesh.Vertices.Skip(mesh.Faces[i] * 3).Take(3)); ls.Add(HelperClass.NodeAt(mesh.Vertices[mesh.Faces[i] * 3], mesh.Vertices[mesh.Faces[i] * 3 + 1], mesh.Vertices[mesh.Faces[i] * 3 + 2], Initialiser.Settings.CoincidentNodeAllowance).ToString()); } ls.Add("0"); //Orientation node try { ls.Add(HelperClass.Get2DAngle(coor.ToArray(), mesh.Axis).ToString()); } catch { ls.Add("0"); } ls.Add("NO_RLS"); ls.Add("0"); // Offset x-start ls.Add("0"); // Offset x-end ls.Add("0"); // Offset y ls.Add(mesh.Offset.ToString()); //ls.Add("NORMAL"); // Action // TODO: EL.4 SUPPORT ls.Add((mesh.GSADummy.HasValue && mesh.GSADummy.Value) ? "DUMMY" : ""); return(string.Join("\t", ls)); }
public string SetGWACommand(int group = 0) { if (this.Value == null) { return(""); } var mesh = this.Value as Structural2DElementMesh; var keyword = typeof(GSA2DMember).GetGSAKeyword(); var index = Initialiser.Cache.ResolveIndex(typeof(GSA2DMember).GetGSAKeyword(), mesh.ApplicationId); var propRef = 0; try { propRef = Initialiser.Cache.LookupIndex(typeof(GSA2DProperty).GetGSAKeyword(), mesh.PropertyRef).Value; } catch { } var gwaCommands = new List <string>(); var ls = new List <string> { "SET", keyword + ":" + HelperClass.GenerateSID(mesh), index.ToString(), mesh.Name == null || mesh.Name == "" ? " " : mesh.Name, mesh.Colors == null || mesh.Colors.Count() < 1 ? "NO_RGB" : mesh.Colors[0].ArgbToHexColor().ToString() }; if (mesh.ElementType == Structural2DElementType.Slab) { ls.Add("SLAB"); } else if (mesh.ElementType == Structural2DElementType.Wall) { ls.Add("WALL"); } else { ls.Add("2D_GENERIC"); } ls.Add(propRef.ToString()); ls.Add(group != 0 ? group.ToString() : index.ToString()); // TODO: This allows for targeting of elements from members group var topo = ""; var prevNodeIndex = -1; var connectivities = mesh.Edges(); var coor = new List <double>(); foreach (var c in connectivities[0]) { coor.AddRange(mesh.Vertices.Skip(c * 3).Take(3)); var currIndex = HelperClass.NodeAt(mesh.Vertices[c * 3], mesh.Vertices[c * 3 + 1], mesh.Vertices[c * 3 + 2], Initialiser.Settings.CoincidentNodeAllowance); if (prevNodeIndex != currIndex) { topo += currIndex.ToString() + " "; } prevNodeIndex = currIndex; } ls.Add(topo.Trim()); ls.Add("0"); // Orientation node try { ls.Add(HelperClass.Get2DAngle(coor.ToArray(), mesh.Axis.First()).ToString()); } catch { ls.Add("0"); } ls.Add(mesh.GSAMeshSize == 0 ? "1" : mesh.GSAMeshSize.ToString()); // Target mesh size ls.Add("MESH"); // TODO: What is this? ls.Add("LINEAR"); // Element type ls.Add("0"); // Fire ls.Add("0"); // Time 1 ls.Add("0"); // Time 2 ls.Add("0"); // Time 3 ls.Add("0"); // TODO: What is this? ls.Add((mesh.GSADummy.HasValue && mesh.GSADummy.Value) ? "DUMMY" : "ACTIVE"); ls.Add("NO"); // Internal auto offset ls.Add((mesh.Offset != null && mesh.Offset.Count() > 0) ? mesh.Offset.First().ToString() : "0"); // Offset z ls.Add("ALL"); // Exposure gwaCommands.Add(string.Join("\t", ls)); // Add voids foreach (var conn in connectivities.Skip(1)) { ls.Clear(); index = Initialiser.Cache.ResolveIndex(typeof(GSA2DVoid).GetGSAKeyword()); ls.Add("SET"); ls.Add(keyword + ":" + HelperClass.GenerateSID(mesh)); ls.Add(index.ToString()); ls.Add(mesh.Name == null || mesh.Name == "" ? " " : mesh.Name); ls.Add(mesh.Colors == null || mesh.Colors.Count() < 1 ? "NO_RGB" : mesh.Colors[0].ArgbToHexColor().ToString()); ls.Add("2D_VOID_CUTTER"); ls.Add("1"); // Property reference ls.Add("0"); // Group topo = ""; prevNodeIndex = -1; coor.Clear(); foreach (var c in conn) { coor.AddRange(mesh.Vertices.Skip(c * 3).Take(3)); var currIndex = HelperClass.NodeAt(mesh.Vertices[c * 3], mesh.Vertices[c * 3 + 1], mesh.Vertices[c * 3 + 2], Initialiser.Settings.CoincidentNodeAllowance); if (prevNodeIndex != currIndex) { topo += currIndex.ToString() + " "; } prevNodeIndex = currIndex; } ls.Add(topo); ls.Add("0"); // Orientation node ls.Add("0"); // Angles ls.Add("1"); // Target mesh size ls.Add("MESH"); // TODO: What is this? ls.Add("LINEAR"); // Element type ls.Add("0"); // Fire ls.Add("0"); // Time 1 ls.Add("0"); // Time 2 ls.Add("0"); // Time 3 ls.Add("0"); // TODO: What is this? ls.Add("ACTIVE"); // Dummy ls.Add("NO"); // Internal auto offset ls.Add("0"); // Offset z ls.Add("ALL"); // Exposure gwaCommands.Add(string.Join("\t", ls)); } return(string.Join("\n", gwaCommands)); }