Exemplo n.º 1
0
    public string SetGWACommand()
    {
      if (this.Value == null)
        return "";

      var destType = typeof(GSASpringProperty);

      var springProp = this.Value as StructuralSpringProperty;
      if (springProp.SpringType == StructuralSpringPropertyType.NotSet)
        return "";

      var keyword = destType.GetGSAKeyword();

      var index = Initialiser.AppResources.Cache.ResolveIndex(keyword, springProp.ApplicationId);

      var gwaCommands = new List<string>();

      var sid = Helper.GenerateSID(springProp);
      var ls = new List<string>
      {
        "SET",
        keyword + (string.IsNullOrEmpty(sid) ? "" : ":" + sid),
        index.ToString(),
        string.IsNullOrEmpty(springProp.Name) ? "" : springProp.Name,
        "NO_RGB"
      };

      ls.AddRange(SpringTypeCommandPieces(springProp.SpringType, springProp.Stiffness, springProp.DampingRatio ?? 0));

      gwaCommands.Add(string.Join(Initialiser.AppResources.Proxy.GwaDelimiter.ToString(), ls));

      return string.Join("\n", gwaCommands);
    }
Exemplo n.º 2
0
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }
            var infl = this.Value as Structural1DInfluenceEffect;

            var keyword = typeof(GSA1DInfluenceEffect).GetGSAKeyword();

            var index = Initialiser.AppResources.Cache.ResolveIndex(typeof(GSA1DInfluenceEffect).GetGSAKeyword(), infl.ApplicationId);

            var elementRef = Initialiser.AppResources.Cache.LookupIndex(typeof(GSA1DElement).GetGSAKeyword(), infl.ElementRef);

            if (!elementRef.HasValue)
            {
                return("");
            }

            var direction = new string[6] {
                "X", "Y", "Z", "XX", "YY", "ZZ"
            };

            var gwaCommands = new List <string>();

            //This causes multiple lines to have the same application ID - might need a review
            var sid = Helper.GenerateSID(infl);

            for (var i = 0; i < infl.Directions.Value.Count(); i++)
            {
                var ls = new List <string>
                {
                    "SET_AT",
                    index.ToString(),
                    keyword + (string.IsNullOrEmpty(sid) ? "" : ":" + sid),
                    infl.Name == null || infl.Name == "" ? " " : infl.Name,
                    infl.GSAEffectGroup.ToString(),
                    elementRef.Value.ToString(),
                    (infl.Position * 100).ToString() + "%",
                    infl.Factor.ToString()
                };
                switch (infl.EffectType)
                {
                case StructuralInfluenceEffectType.Force:
                    ls.Add("FORCE");
                    break;

                case StructuralInfluenceEffectType.Displacement:
                    ls.Add("DISP");
                    break;

                default:
                    return("");
                }
                ls.Add("GLOBAL"); // TODO: GSA TEAM TO LOOK INTO THIS. GLOBAL IS DEFAULT IN GSA
                ls.Add(direction[i]);
                gwaCommands.Add(string.Join(Initialiser.AppResources.Proxy.GwaDelimiter.ToString(), ls));
            }
            return(string.Join("\n", gwaCommands));
        }
Exemplo n.º 3
0
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }

            var load = this.Value as StructuralGravityLoading;

            if (load.GravityFactors == null)
            {
                return("");
            }

            var keyword = typeof(GSAGravityLoading).GetGSAKeyword();

            var loadCaseKeyword = typeof(GSALoadCase).GetGSAKeyword();
            var indexResult     = Initialiser.AppResources.Cache.LookupIndex(loadCaseKeyword, load.LoadCaseRef);
            var loadCaseRef     = indexResult ?? Initialiser.AppResources.Cache.ResolveIndex(loadCaseKeyword, load.LoadCaseRef);

            if (indexResult == null && load.ApplicationId != null)
            {
                if (load.LoadCaseRef == null)
                {
                    Initialiser.AppResources.Messenger.Message(MessageIntent.Display, MessageLevel.Error, "Blank load case references found for these Application IDs:",
                                                               load.ApplicationId);
                }
                else
                {
                    Initialiser.AppResources.Messenger.Message(MessageIntent.Display, MessageLevel.Error, "Load case references not found:",
                                                               load.ApplicationId + " referencing " + load.LoadCaseRef);
                }
            }

            var index = Initialiser.AppResources.Cache.ResolveIndex(typeof(GSAGravityLoading).GetGSAKeyword());

            var sid = Helper.GenerateSID(load);
            var ls  = new List <string>
            {
                "SET_AT",
                index.ToString(),
                keyword + (string.IsNullOrEmpty(sid) ? "" : ":" + sid),
                string.IsNullOrEmpty(load.Name) ? "" : load.Name,
                "all",
                "all",
                loadCaseRef.ToString(),
                load.GravityFactors.Value[0].ToString(),
                load.GravityFactors.Value[1].ToString(),
                load.GravityFactors.Value[2].ToString(),
            };

            return(string.Join(Initialiser.AppResources.Proxy.GwaDelimiter.ToString(), ls));
        }
Exemplo n.º 4
0
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }

            var obj = this.Value as StructuralStagedNodalRestraints;

            if (obj.Restraint == null)
            {
                return("");
            }

            var destinationType = typeof(GSAStagedNodalRestraints);

            var keyword     = destinationType.GetGSAKeyword();
            var subkeywords = destinationType.GetSubGSAKeyword();

            var index = Initialiser.AppResources.Cache.ResolveIndex(keyword, obj.ApplicationId);

            var nodesStr = "none"; //default value

            if (obj.NodeRefs != null && obj.NodeRefs.Count() >= 1)
            {
                var nodeIndices = Initialiser.AppResources.Cache.LookupIndices(typeof(GSANode).GetGSAKeyword(), obj.NodeRefs).Distinct().OrderBy(i => i);
                nodesStr = string.Join(" ", nodeIndices);
            }

            var stageDefStr = "all"; //default value

            if (obj.ConstructionStageRefs != null && obj.ConstructionStageRefs.Count() >= 1)
            {
                var stageDefIndices = Initialiser.AppResources.Cache.LookupIndices(typeof(GSAConstructionStage).GetGSAKeyword(), obj.ConstructionStageRefs).Distinct().OrderBy(i => i);
                stageDefStr = string.Join(" ", stageDefIndices);
            }

            var sid = Helper.GenerateSID(obj);
            var ls  = new List <string>
            {
                "SET_AT",
                index.ToString(),
                keyword + (string.IsNullOrEmpty(sid) ? "" : ":" + sid),
                string.IsNullOrEmpty(obj.Name) ? " " : obj.Name
            };

            ls.AddRange(obj.Restraint.Value.Select(v => v ? "1" : "0"));
            ls.Add(nodesStr);
            ls.Add(stageDefStr);

            return(string.Join(Initialiser.AppResources.Proxy.GwaDelimiter.ToString(), ls));
        }
Exemplo n.º 5
0
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }

            var destType = typeof(GSABridgeVehicle);

            var vehicle = this.Value as StructuralBridgeVehicle;

            if (vehicle.ApplicationId == null)
            {
                return("");
            }

            var keyword = destType.GetGSAKeyword();

            var index = Initialiser.AppResources.Cache.ResolveIndex(keyword, vehicle.ApplicationId);

            //The width parameter is intentionally not being used here as the meaning doesn't map to the y coordinate parameter of the ASSEMBLY keyword
            //It is therefore to be ignored here for GSA purposes.

            var sid = Helper.GenerateSID(vehicle);
            //the sid shouldn't be blank because the applicationId never being negative due to the test earlier, but the check below
            //has been included for consistency with other conversion code
            var ls = new List <string>
            {
                "SET",
                keyword + (string.IsNullOrEmpty(sid) ? "" : ":" + sid),
                index.ToString(),
                string.IsNullOrEmpty(vehicle.Name) ? "" : vehicle.Name,
                ((vehicle.Width == null) ? 0 : vehicle.Width).ToString(),
                ((vehicle.Axles == null) ? 0 : vehicle.Axles.Count()).ToString()
            };

            if (vehicle.Axles != null && vehicle.Axles.Count() > 0)
            {
                foreach (var axle in vehicle.Axles)
                {
                    ls.AddRange(new[] {
                        axle.Position.ToString(),
                        axle.WheelOffset.ToString(),
                        axle.LeftWheelLoad.ToString(),
                        axle.RightWheelLoad.ToString()
                    });
                }
            }

            return(string.Join(Initialiser.AppResources.Proxy.GwaDelimiter.ToString(), ls));
        }
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }

            var plane = this.Value as StructuralLoadPlane;

            if (plane.ApplicationId == null)
            {
                return("");
            }

            var keyword = typeof(GSAGridSurface).GetGSAKeyword();
            var index   = Initialiser.Cache.ResolveIndex(keyword);

            int gridPlaneIndex;

            var gwaCommands = new List <string>();

            if (plane.Axis != null)
            {
                gwaCommands.AddRange(SetAxisPlaneGWACommands(plane.Axis, plane.Name, out gridPlaneIndex));
            }
            else if (plane.Axis == null && !string.IsNullOrEmpty(plane.StoreyRef))
            {
                gridPlaneIndex = Initialiser.Cache.ResolveIndex(typeof(GSAStorey).GetGSAKeyword(), plane.StoreyRef);
            }
            else
            {
                return("");
            }

            var ls = new List <string>();

            ls.AddRange(new[] { "SET",
                                keyword + ":" + Helper.GenerateSID(plane),
                                index.ToString(),
                                plane.Name == null || plane.Name == "" ? " " : plane.Name,
                                gridPlaneIndex.ToString(),
                                (plane.ElementDimension ?? 1).ToString(),                       // Dimension of elements to target
                                "all",                                                          // List of elements to target
                                (plane.Tolerance ?? 0.01).ToString(),                           // Tolerance
                                (plane.Span == null || plane.Span == 2) ? "TWO_SIMPLE" : "ONE", // Span option
                                (plane.SpanAngle ?? 0).ToString() });                           // Span angle

            gwaCommands.Add(string.Join("\t", ls));

            return(string.Join("\n", gwaCommands));
        }
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }

            var load = this.Value as StructuralGravityLoading;

            if (load.GravityFactors == null)
            {
                return("");
            }

            var keyword = typeof(GSAGravityLoading).GetGSAKeyword();

            var loadCaseKeyword = typeof(GSALoadCase).GetGSAKeyword();
            var indexResult     = Initialiser.Cache.LookupIndex(loadCaseKeyword, load.LoadCaseRef);
            var loadCaseRef     = indexResult ?? Initialiser.Cache.ResolveIndex(loadCaseKeyword, load.LoadCaseRef);

            if (indexResult == null && load.ApplicationId != null)
            {
                if (load.LoadCaseRef == null)
                {
                    Helper.SafeDisplay("Blank load case references found for these Application IDs:", load.ApplicationId);
                }
                else
                {
                    Helper.SafeDisplay("Load case references not found:", load.ApplicationId + " referencing " + load.LoadCaseRef);
                }
            }

            var index = Initialiser.Cache.ResolveIndex(typeof(GSAGravityLoading).GetGSAKeyword());

            var ls = new List <string>
            {
                "SET_AT",
                index.ToString(),
                keyword + ":" + Helper.GenerateSID(load),
                string.IsNullOrEmpty(load.Name) ? "" : load.Name,
                "all",
                loadCaseRef.ToString(),
                load.GravityFactors.Value[0].ToString(),
                load.GravityFactors.Value[1].ToString(),
                load.GravityFactors.Value[2].ToString(),
            };

            return(string.Join("\t", ls));
        }
Exemplo n.º 8
0
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }

            var destType = typeof(GSABridgeVehicle);

            var vehicle = this.Value as StructuralBridgeVehicle;

            if (vehicle.ApplicationId == null)
            {
                return("");
            }

            var keyword = destType.GetGSAKeyword();

            var index = Initialiser.Cache.ResolveIndex(keyword, vehicle.ApplicationId);

            //The width parameter is intentionally not being used here as the meaning doesn't map to the y coordinate parameter of the ASSEMBLY keyword
            //It is therefore to be ignored here for GSA purposes.

            var ls = new List <string>
            {
                "SET",
                keyword + ":" + Helper.GenerateSID(vehicle),
                index.ToString(),
                string.IsNullOrEmpty(vehicle.Name) ? "" : vehicle.Name,
                ((vehicle.Width == null) ? 0 : vehicle.Width).ToString(),
                ((vehicle.Axles == null) ? 0 : vehicle.Axles.Count()).ToString()
            };

            if (vehicle.Axles != null && vehicle.Axles.Count() > 0)
            {
                foreach (var axle in vehicle.Axles)
                {
                    ls.AddRange(new[] {
                        axle.Position.ToString(),
                        axle.WheelOffset.ToString(),
                        axle.LeftWheelLoad.ToString(),
                        axle.RightWheelLoad.ToString()
                    });
                }
            }

            return(string.Join("\t", ls));
        }
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }

            var destType = typeof(GSABridgePath);

            var path = this.Value as StructuralBridgePath;

            if (string.IsNullOrEmpty(path.ApplicationId))
            {
                return("");
            }

            var keyword = destType.GetGSAKeyword();

            var index          = Initialiser.AppResources.Cache.ResolveIndex(keyword, path.ApplicationId);
            var alignmentIndex = Initialiser.AppResources.Cache.LookupIndex(typeof(GSABridgeAlignment).GetGSAKeyword(), path.AlignmentRef) ?? 1;

            var left  = (path.Offsets == null || path.Offsets.Count() == 0) ? 0 : path.Offsets.First();
            var right = (path.PathType == StructuralBridgePathType.Track || path.PathType == StructuralBridgePathType.Vehicle)
        ? path.Gauge
        : (path.Offsets == null || path.Offsets.Count() == 0) ? 0 : path.Offsets.Last();

            var sid = Helper.GenerateSID(path);
            var ls  = new List <string>
            {
                "SET",
                keyword + (string.IsNullOrEmpty(sid) ? "" : ":" + sid),
                index.ToString(),
                string.IsNullOrEmpty(path.Name) ? "" : path.Name,
                PathTypeToGWAString(path.PathType),
                "1", //Group
                alignmentIndex.ToString(),
                left.ToString(),
                right.ToString(),
                path.LeftRailFactor.ToString()
            };

            return(string.Join(Initialiser.AppResources.Proxy.GwaDelimiter.ToString(), ls));
        }
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }

            var destType = typeof(GSAGridLine);

            var gridLine = this.Value as StructuralReferenceLine;

            if (gridLine.ApplicationId == null)
            {
                return("");
            }

            var keyword = destType.GetGSAKeyword();

            var index = Initialiser.AppResources.Cache.ResolveIndex(keyword, gridLine.ApplicationId);

            //The width parameter is intentionally not being used here as the meaning doesn't map to the y coordinate parameter of the ASSEMBLY keyword
            //It is therefore to be ignored here for GSA purposes.

            var line         = new Line2D(new Point2D(gridLine.Value[0], gridLine.Value[1]), new Point2D(gridLine.Value[3], gridLine.Value[4]));
            var angleDegrees = (new Vector2D(1, 0)).AngleTo(line.Direction).Degrees;

            var sid = Helper.GenerateSID(gridLine);
            var ls  = new List <string>
            {
                "SET",
                keyword + (string.IsNullOrEmpty(sid) ? "" : ":" + sid),
                index.ToString(),
                string.IsNullOrEmpty(gridLine.Name) ? "" : gridLine.Name,
                "LINE",
                gridLine.Value[0].ToString(),
                gridLine.Value[1].ToString(),
                angleDegrees.ToString(),
                "0" //ignored as the angle is in degrees
            };

            return(string.Join(Initialiser.AppResources.Proxy.GwaDelimiter.ToString(), ls));
        }
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }

            var storey = this.Value as StructuralStorey;

            if (storey.ApplicationId == null)
            {
                return("");
            }

            var axis = (storey.Axis == null) ? new StructuralAxis(new StructuralVectorThree(1, 0, 0), new StructuralVectorThree(0, 1, 0)) : storey.Axis;

            var gwaCommands = SetAxisPlaneGWACommands(axis, storey.Name, out var gridPlaneIndex, storey.Elevation, storey.ToleranceAbove, storey.ToleranceBelow,
                                                      GridPlaneType.Storey, Helper.GenerateSID(storey));

            return(string.Join("\n", gwaCommands));
        }
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }

            var mat = this.Value as StructuralMaterialSteel;

            if (mat.ApplicationId == null)
            {
                return("");
            }

            var keyword = typeof(GSAMaterialSteel).GetGSAKeyword();

            var index = Initialiser.Cache.ResolveIndex(typeof(GSAMaterialSteel).GetGSAKeyword(), mat.ApplicationId);

            // TODO: This function barely works.
            var ls = new List <string>
            {
                "SET",
                "MAT_STEEL.3" + ":" + Helper.GenerateSID(mat),
                index.ToString(),
                "MAT.8",
                mat.Name == null || mat.Name == "" ? " " : mat.Name,
                "YES",                                // Unlocked
                mat.YoungsModulus.ToString(),         // E
                mat.PoissonsRatio.ToString(),         // nu
                mat.ShearModulus.ToString(),          // G
                mat.Density.ToString(),               // rho
                mat.CoeffThermalExpansion.ToString(), // alpha
                "MAT_ANAL.1",
                "Steel",
                "-268435456",                         // TODO: What is this?
                "MAT_ELAS_ISO",
                "6",                                  // TODO: What is this?
                mat.YoungsModulus.ToString(),         // E
                mat.PoissonsRatio.ToString(),         // nu
                mat.Density.ToString(),               // rho
                mat.CoeffThermalExpansion.ToString(), // alpha
                mat.ShearModulus.ToString(),          // G
                "0",                                  // TODO: What is this?
                "0",                                  // TODO: What is this?
                "0",                                  // TODO: What is this?
                "0",                                  // TODO: What is this?
                "0",                                  // TODO: What is this?
                "0",                                  // TODO: What is this?
                "0",                                  // TODO: What is this?
                mat.MaxStrain.ToString(),             // Ultimate strain
                "MAT_CURVE_PARAM.2",
                "",
                "UNDEF",
                "1", // Material factor on strength
                "1", // Material factor on elastic modulus
                "MAT_CURVE_PARAM.2",
                "",
                "UNDEF",
                "1",                             // Material factor on strength
                "1",                             // Material factor on elastic modulus
                "0",                             // Cost
                mat.YieldStrength.ToString(),    // Yield strength
                mat.UltimateStrength.ToString(), // Ultimate strength
                "0",                             // Perfectly plastic strain limit
                "0"                              // Hardening modulus
            };

            return(string.Join("\t", ls));
        }
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }

            var node = this.Value as StructuralNode;

            if (node.Value == null || node.Value.Count() != 3)
            {
                return("");
            }

            var keyword = typeof(GSANode).GetGSAKeyword();

            var index = Helper.NodeAt(node.Value[0], node.Value[1], node.Value[2], Initialiser.Settings.CoincidentNodeAllowance);

            var ls = new List <string>
            {
                "SET",
                keyword + ":" + Helper.GenerateSID(node),
                index.ToString(),
                node.Name == null || node.Name == "" ? " " : node.Name,
                "NO_RGB",
                string.Join("\t", node.Value.Select(v => Math.Round(v, 8)).ToArray()), //GSA seems to round to 8 here

                //ls.Add("0"); // TODO: Skip unknown fields in NODE.3
                //ls.Add("0"); // TODO: Skip unknown fields in NODE.3
                //ls.Add("0"); // TODO: Skip unknown fields in NODE.3

                "NO_GRID"
            };


            var gwaCommands = new List <string>();
            var axisGwa     = "";

            try
            {
                Helper.SetAxis(node.Axis, out var axisIndex, out axisGwa, node.Name);
                if (axisGwa.Length > 0)
                {
                    gwaCommands.Add(axisGwa);
                }

                ls.Add(axisIndex.ToString());
            }
            catch { ls.Add("0"); }

            try
            {
                if (node.Restraint == null || !node.Restraint.Value.Any(x => x))
                {
                    ls.Add("NO_REST");
                }
                else
                {
                    var subLs = new List <string>
                    {
                        "REST",
                        node.Restraint.Value[0] ? "1" : "0",
                        node.Restraint.Value[1] ? "1" : "0",
                        node.Restraint.Value[2] ? "1" : "0",
                        node.Restraint.Value[3] ? "1" : "0",
                        node.Restraint.Value[4] ? "1" : "0",
                        node.Restraint.Value[5] ? "1" : "0"
                    };
                    ls.AddRange(subLs);
                }
            }
            catch { ls.Add("NO_REST"); }


            if ((node.Stiffness == null || !node.Stiffness.Value.Any(x => x == 0)) &&
                (node.GSALocalMeshSize == 0))
            {
                //GSA leaves the rest off the GWA in this case
            }
            else
            {
                try
                {
                    if (node.Stiffness == null || !node.Stiffness.Value.Any(x => x == 0))
                    {
                        ls.Add("NO_STIFF");
                    }
                    else
                    {
                        var subLs = new List <string>
                        {
                            "STIFF",
                            node.Stiffness.Value[0].ToString(),
                            node.Stiffness.Value[1].ToString(),
                            node.Stiffness.Value[2].ToString(),
                            node.Stiffness.Value[3].ToString(),
                            node.Stiffness.Value[4].ToString(),
                            node.Stiffness.Value[5].ToString()
                        };
                        ls.AddRange(subLs);
                    }
                }
                catch { ls.Add("NO_STIFF"); }

                try
                {
                    if (node.GSALocalMeshSize == 0)
                    {
                        //GSA seems to leave this off if there is no mesh
                        //ls.Add("NO_MESH");
                    }
                    else
                    {
                        var subLs = new List <string>
                        {
                            "MESH",
                            node.GSALocalMeshSize.ToString(),
                            "0",  // Radius
                            "NO", // Tie to mesh
                            "NO", // column rigidity will be generated
                            "0",  // Column property number
                            "0",  //Column orientation node
                            "0",  //Column orientation angle
                            "1",  //Column dimension factor
                            "0"   //Column slab thickness factor
                        };

                        ls.AddRange(subLs);
                    }
                }
                catch (Exception)
                {
                    ls.Add("NO_MESH");
                }
            }

            gwaCommands.Add(string.Join("\t", ls));

            return(string.Join("\n", gwaCommands));
        }
        public string SetGWACommand(string GSAUnits)
        {
            if (this.Value == null)
            {
                return("");
            }

            var prop = this.Value as Structural1DProperty;

            if (prop.Profile == null && string.IsNullOrEmpty(prop.CatalogueName))
            {
                return("");
            }

            var keyword = typeof(GSA1DProperty).GetGSAKeyword();

            var index        = Initialiser.Cache.ResolveIndex(typeof(GSA1DProperty).GetGSAKeyword(), prop.ApplicationId);
            var materialRef  = 0;
            var materialType = "UNDEF";

            var res = Initialiser.Cache.LookupIndex(typeof(GSAMaterialSteel).GetGSAKeyword(), prop.MaterialRef);

            if (res.HasValue)
            {
                materialRef  = res.Value;
                materialType = "STEEL";
            }
            else
            {
                res = Initialiser.Cache.LookupIndex(typeof(GSAMaterialConcrete).GetGSAKeyword(), prop.MaterialRef);
                if (res.HasValue)
                {
                    materialRef  = res.Value;
                    materialType = "CONCRETE";
                }
            }
            if (materialRef == 0)
            {
                //If the material reference can't be resolved, then point to generic material (which this code doesn't create anywhere else) with reference 1
                materialRef  = 1;
                materialType = "GENERIC";
            }

            var ls = new List <string>
            {
                "SET",
                keyword + ":" + Helper.GenerateSID(prop),
                index.ToString(),
                prop.Name == null || prop.Name == "" ? " " : prop.Name,
                "NO_RGB",
                materialType,
                materialRef.ToString(),
                "0",        // Analysis material
                GetGSADesc(prop, GSAUnits),
                "0",        // Cost
                "CENTROID", //this needs review
                "0",        //this needs review
                "0"         //this needs review
            };

            return(string.Join("\t", ls));
        }
Exemplo n.º 15
0
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }

            var loadTask = this.Value as StructuralLoadTask;

            if (string.IsNullOrEmpty(loadTask.ApplicationId))
            {
                return("");
            }

            var keyword = typeof(GSALoadTask).GetGSAKeyword();

            var taskIndex = Initialiser.AppResources.Cache.ResolveIndex("TASK.2", loadTask.ApplicationId);
            var index     = Initialiser.AppResources.Cache.ResolveIndex(typeof(GSALoadTask).GetGSAKeyword(), loadTask.ApplicationId);

            var gwaCommands = new List <string>();

            var ls = new List <string>
            {
                // Set TASK
                "SET",
                "TASK.2" + ":" + Helper.GenerateSID(loadTask),
                taskIndex.ToString(),
                "", // Name
                "0" // Stage
            };

            switch (loadTask.TaskType)
            {
            case StructuralLoadTaskType.LinearStatic:
                ls.Add("GSS");
                ls.Add("STATIC");
                // Defaults:
                ls.Add("1");
                ls.Add("0");
                ls.Add("128");
                ls.Add("SELF");
                ls.Add("none");
                ls.Add("none");
                ls.Add("DRCMEFNSQBHU*");
                ls.Add("MIN");
                ls.Add("AUTO");
                ls.Add("0");
                ls.Add("0");
                ls.Add("0");
                ls.Add("NONE");
                ls.Add("FATAL");
                ls.Add("NONE");
                ls.Add("NONE");
                ls.Add("RAFT_LO");
                ls.Add("RESID_NO");
                ls.Add("0");
                ls.Add("1");
                ls.Add("0");
                break;

            case StructuralLoadTaskType.NonlinearStatic:
                ls.Add("GSRELAX");
                ls.Add("BUCKLING_NL");
                // Defaults:
                ls.Add("SINGLE");
                ls.Add("0");
                ls.Add("BEAM_GEO_YES");
                ls.Add("SHELL_GEO_NO");
                ls.Add("0.1");
                ls.Add("0.0001");
                ls.Add("0.1");
                ls.Add("CYCLE");
                ls.Add("100000");
                ls.Add("REL");
                ls.Add("0.0010000000475");
                ls.Add("0.0010000000475");
                ls.Add("DISP_CTRL_YES");
                ls.Add("0");
                ls.Add("1");
                ls.Add("0.01");
                ls.Add("LOAD_CTRL_NO");
                ls.Add("1");
                ls.Add("");
                ls.Add("10");
                ls.Add("100");
                ls.Add("RESID_NOCONV");
                ls.Add("DAMP_VISCOUS");
                ls.Add("0");
                ls.Add("0");
                ls.Add("1");
                ls.Add("1");
                ls.Add("1");
                ls.Add("1");
                ls.Add("AUTO_MASS_YES");
                ls.Add("AUTO_DAMP_YES");
                ls.Add("FF_SAVE_ELEM_FORCE_YES");
                ls.Add("FF_SAVE_SPACER_FORCE_TO_ELEM");
                ls.Add("DRCEFNSQBHU*");
                break;

            case StructuralLoadTaskType.Modal:
                ls.Add("GSS");
                ls.Add("MODAL");
                // Defaults:
                ls.Add("1");
                ls.Add("1");
                ls.Add("128");
                ls.Add("SELF");
                ls.Add("none");
                ls.Add("none");
                ls.Add("DRCMEFNSQBHU*");
                ls.Add("MIN");
                ls.Add("AUTO");
                ls.Add("0");
                ls.Add("0");
                ls.Add("0");
                ls.Add("NONE");
                ls.Add("FATAL");
                ls.Add("NONE");
                ls.Add("NONE");
                ls.Add("RAFT_LO");
                ls.Add("RESID_NO");
                ls.Add("0");
                ls.Add("1");
                ls.Add("0");
                break;

            default:
                ls.Add("GSS");
                ls.Add("STATIC");
                // Defaults:
                ls.Add("1");
                ls.Add("0");
                ls.Add("128");
                ls.Add("SELF");
                ls.Add("none");
                ls.Add("none");
                ls.Add("DRCMEFNSQBHU*");
                ls.Add("MIN");
                ls.Add("AUTO");
                ls.Add("0");
                ls.Add("0");
                ls.Add("0");
                ls.Add("NONE");
                ls.Add("FATAL");
                ls.Add("NONE");
                ls.Add("NONE");
                ls.Add("RAFT_LO");
                ls.Add("RESID_NO");
                ls.Add("0");
                ls.Add("1");
                ls.Add("0");
                break;
            }
            gwaCommands.Add(string.Join(Initialiser.AppResources.Proxy.GwaDelimiter.ToString(), ls));

            // Set ANAL
            ls.Clear();
            ls.Add("SET");
            var sid = Helper.GenerateSID(loadTask);

            ls.Add(keyword + (string.IsNullOrEmpty(sid) ? "" : ":" + sid));
            ls.Add(index.ToString());
            ls.Add(loadTask.Name == null || loadTask.Name == "" ? " " : loadTask.Name);
            ls.Add(taskIndex.ToString());
            if (loadTask.TaskType == StructuralLoadTaskType.Modal)
            {
                ls.Add("M1");
            }
            else
            {
                if (loadTask.LoadCaseRefs != null)
                {
                    var subLs = new List <string>();
                    for (var i = 0; i < loadTask.LoadCaseRefs.Count(); i++)
                    {
                        var loadCaseRef = Initialiser.AppResources.Cache.LookupIndex(typeof(GSALoadCase).GetGSAKeyword(), loadTask.LoadCaseRefs[i]);

                        if (loadCaseRef.HasValue)
                        {
                            if (loadTask.LoadFactors != null && loadTask.LoadFactors.Count() > i)
                            {
                                subLs.Add(loadTask.LoadFactors[i].ToString() + "L" + loadCaseRef.Value.ToString());
                            }
                            else
                            {
                                subLs.Add("L" + loadCaseRef.Value.ToString());
                            }
                        }
                    }
                    ls.Add(string.Join(" + ", subLs));
                }
            }
            gwaCommands.Add(string.Join(Initialiser.AppResources.Proxy.GwaDelimiter.ToString(), ls));
            return(string.Join("\n", gwaCommands));
        }
Exemplo n.º 16
0
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }

            var loadCombo = this.Value as StructuralLoadCombo;

            if (string.IsNullOrEmpty(loadCombo.ApplicationId))
            {
                return("");
            }

            var keyword = typeof(GSALoadCombo).GetGSAKeyword();

            var index = Initialiser.AppResources.Cache.ResolveIndex(typeof(GSALoadCombo).GetGSAKeyword(), loadCombo.ApplicationId);

            var sid = Helper.GenerateSID(loadCombo);
            var ls  = new List <string>
            {
                "SET",
                keyword + (string.IsNullOrEmpty(sid) ? "" : ":" + sid),
                index.ToString(),
                loadCombo.Name == null || loadCombo.Name == "" ? " " : loadCombo.Name
            };

            var subLs = new List <string>();

            if (loadCombo.LoadTaskRefs != null)
            {
                for (var i = 0; i < loadCombo.LoadTaskRefs.Count(); i++)
                {
                    var loadTaskRef = Initialiser.AppResources.Cache.LookupIndex(typeof(GSALoadTask).GetGSAKeyword(), loadCombo.LoadTaskRefs[i]);

                    if (loadTaskRef.HasValue)
                    {
                        subLs.Add((loadCombo.LoadTaskFactors != null && loadCombo.LoadTaskFactors.Count() > i)
              ? loadCombo.LoadTaskFactors[i].ToString() + "A" + loadTaskRef.Value.ToString()
              : "A" + loadTaskRef.Value.ToString());
                    }
                }
            }

            if (loadCombo.LoadComboRefs != null)
            {
                for (var i = 0; i < loadCombo.LoadComboRefs.Count(); i++)
                {
                    var loadComboRef = Initialiser.AppResources.Cache.LookupIndex(typeof(GSALoadTask).GetGSAKeyword(), loadCombo.LoadComboRefs[i]);

                    if (loadComboRef.HasValue)
                    {
                        subLs.Add((loadCombo.LoadComboFactors != null && loadCombo.LoadComboFactors.Count() > i)
              ? loadCombo.LoadComboFactors[i].ToString() + "C" + loadComboRef.Value.ToString()
              : "C" + loadComboRef.Value.ToString());
                    }
                }
            }

            switch (loadCombo.ComboType)
            {
            case StructuralLoadComboType.LinearAdd:
                ls.Add(string.Join(" + ", subLs));
                break;

            case StructuralLoadComboType.Envelope:
                ls.Add(string.Join(" or ", subLs));
                break;

            default:
                ls.Add(string.Join(" + ", subLs));
                break;
            }

            return(string.Join(Initialiser.AppResources.Proxy.GwaDelimiter.ToString(), ls));
        }
Exemplo n.º 17
0
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }

            var load = this.Value as Structural0DLoadPoint;

            if (load.ApplicationId == null)
            {
                return("");
            }

            var keyword          = typeof(GSA0DLoadPoint).GetGSAKeyword();
            var loadCaseKeyword  = typeof(GSALoadCase).GetGSAKeyword();
            var loadPlaneKeyword = typeof(GSAGridSurface).GetGSAKeyword();

            var axisRef = "GLOBAL";
            int loadCaseRef;

            var gwaCommands = new List <string>();

            var ls = new List <string>();

            try
            {
                loadCaseRef = Initialiser.Cache.LookupIndex(loadCaseKeyword, load.LoadCaseRef).Value;
            }
            catch
            {
                loadCaseRef = Initialiser.Cache.ResolveIndex(loadCaseKeyword, load.LoadCaseRef);
            }

            int gridSurfaceIndex;

            try
            {
                gridSurfaceIndex = Initialiser.Cache.LookupIndex(loadPlaneKeyword, load.LoadPlaneRef).Value;
            }
            catch
            {
                gridSurfaceIndex = Initialiser.Cache.ResolveIndex(loadPlaneKeyword, load.LoadPlaneRef);
            }

            double x = 0;
            double y = 0;

            if (gridSurfaceIndex > 0)
            {
                var loadPlanes = Initialiser.Cache.GetIndicesSpeckleObjects(typeof(StructuralLoadPlane).Name);
                var loadPlane  = ((StructuralLoadPlane)loadPlanes[gridSurfaceIndex]).Axis;

                //Now that load planes are shared, and a new surface and axis aren't created for each point where the point
                //is arranged to be at the origin of the new surface and axis, there might need to be an X and Y coordinate calculated
                //that is relative to the plane
                var axisCoords = Helper.MapPointsGlobal2Local(load.LoadPoint.Value.ToArray(), loadPlane);
                x = axisCoords[0];
                y = axisCoords[1];
            }

            ls.Clear();

            var direction = new string[3] {
                "X", "Y", "Z"
            };

            for (var i = 0; i < Math.Min(direction.Count(), load.Loading.Value.Count()); i++)
            {
                ls.Clear();
                if (load.Loading.Value[i] == 0)
                {
                    continue;
                }

                var index = Initialiser.Cache.ResolveIndex(typeof(GSA0DLoadPoint).GetGSAKeyword());

                ls.Add("SET_AT");
                ls.Add(index.ToString());
                ls.Add(keyword + ":" + Helper.GenerateSID(load));
                ls.Add(load.Name == null || load.Name == "" ? " " : load.Name);
                ls.Add(gridSurfaceIndex.ToString()); // Grid Surface
                ls.Add(x.ToString());                // X coordinate
                ls.Add(y.ToString());                // Y coordinate
                ls.Add(loadCaseRef.ToString());
                ls.Add(axisRef);                     // Axis
                ls.Add(direction[i]);
                ls.Add(load.Loading.Value[i].ToString());

                gwaCommands.Add(string.Join("\t", ls));
            }
            return(string.Join("\n", gwaCommands));
        }
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }

            var load = this.Value as Structural1DLoadLine;

            if (load.ApplicationId == null)
            {
                return("");
            }

            var keyword = typeof(GSAGridLineLoad).GetGSAKeyword();

            //There are no GSA types for these yet, so use empty strings for the type names

            var loadCaseKeyword = typeof(GSALoadCase).GetGSAKeyword();

            var indexResult = Initialiser.AppResources.Cache.LookupIndex(loadCaseKeyword, load.LoadCaseRef);
            var loadCaseRef = indexResult ?? Initialiser.AppResources.Cache.ResolveIndex(loadCaseKeyword, load.LoadCaseRef);

            if (indexResult == null && load.ApplicationId != null)
            {
                if (load.LoadCaseRef == null)
                {
                    Helper.SafeDisplay("Blank load case references found for these Application IDs:", load.ApplicationId);
                }
                else
                {
                    Helper.SafeDisplay("Load case references not found:", load.ApplicationId + " referencing " + load.LoadCaseRef);
                }
            }

            StructuralAxis axis        = null;
            var            ls          = new List <string>();
            var            gwaCommands = new List <string>();
            int            gridSurfaceIndex;

            double elevation = 0;

            if (string.IsNullOrEmpty(load.LoadPlaneRef))
            {
                axis = (load.Value == null)
          ? new StructuralAxis(new StructuralVectorThree(1, 0, 0), new StructuralVectorThree(0, 1, 0))
          : Helper.Parse1DAxis(load.Value.ToArray());

                Helper.SetAxis(axis, out int planeAxisIndex, out string planeAxisGwa, load.Name);
                if (planeAxisGwa.Length > 0)
                {
                    gwaCommands.Add(planeAxisGwa);
                }

                if (load.Value != null)
                {
                    // Calculate elevation
                    elevation = (load.Value[0] * axis.Normal.Value[0] +
                                 load.Value[1] * axis.Normal.Value[1] +
                                 load.Value[2] * axis.Normal.Value[2]) /
                                Math.Sqrt(axis.Normal.Value[0] * axis.Normal.Value[0] +
                                          axis.Normal.Value[1] * axis.Normal.Value[1] +
                                          axis.Normal.Value[2] * axis.Normal.Value[2]);
                }


                gridSurfaceIndex = Initialiser.AppResources.Cache.ResolveIndex("GRID_SURFACE.1");
                var gridPlaneIndex = Initialiser.AppResources.Cache.ResolveIndex("GRID_PLANE.4");

                ls.Clear();
                ls.AddRange(new[] {
                    "SET",
                    "GRID_PLANE.4",
                    gridPlaneIndex.ToString(),
                    load.Name == null || load.Name == "" ? " " : load.Name,
                    "GENERAL", // Type
                    planeAxisIndex.ToString(),
                    elevation.ToString(),
                    "0", // Elevation above
                    "0"
                });      // Elevation below
                gwaCommands.Add(string.Join(Initialiser.AppResources.Proxy.GwaDelimiter.ToString(), ls));

                ls.Clear();
                ls.AddRange(new[] { "SET",
                                    "GRID_SURFACE.1",
                                    gridSurfaceIndex.ToString(),
                                    load.Name == null || load.Name == "" ? " " : load.Name,
                                    gridPlaneIndex.ToString(),
                                    "1",          // Dimension of elements to target
                                    "all",        // List of elements to target
                                    "0.01",       // Tolerance
                                    "TWO_SIMPLE", // Span option
                                    "0" });       // Span angle
                gwaCommands.Add(string.Join(Initialiser.AppResources.Proxy.GwaDelimiter.ToString(), ls));
            }
            else //LoadPlaneRef is not empty/null
            {
                try
                {
                    gridSurfaceIndex = Initialiser.AppResources.Cache.LookupIndex("GRID_SURFACE.1", load.LoadPlaneRef).Value;
                }
                catch
                {
                    gridSurfaceIndex = Initialiser.AppResources.Cache.ResolveIndex("GRID_SURFACE.1", load.LoadPlaneRef);
                }

                var loadPlanesDict = Initialiser.AppResources.Cache.GetIndicesSpeckleObjects(typeof(StructuralLoadPlane).Name);
                if (loadPlanesDict.ContainsKey(gridSurfaceIndex) && loadPlanesDict[gridSurfaceIndex] != null)
                {
                    var loadPlane = ((StructuralLoadPlane)loadPlanesDict[gridSurfaceIndex]);
                    if (loadPlane.Axis != null)
                    {
                        axis = loadPlane.Axis;
                    }
                    else
                    {
                        try
                        {
                            var storeyIndex = Initialiser.AppResources.Cache.LookupIndex("GRID_PLANE.4", loadPlane.StoreyRef).Value;
                            var storeysDict = Initialiser.AppResources.Cache.GetIndicesSpeckleObjects(typeof(StructuralStorey).Name);
                            if (storeysDict.ContainsKey(storeyIndex) && storeysDict[storeyIndex] != null)
                            {
                                var storey = ((StructuralStorey)storeysDict[storeyIndex]);
                                if (storey.Axis != null)
                                {
                                    axis = storey.Axis;
                                }
                            }
                        }
                        catch { }

                        if (axis == null)
                        {
                            axis = new StructuralAxis(new StructuralVectorThree(1, 0, 0), new StructuralVectorThree(0, 1, 0));
                        }
                    }
                }
            }

            // Transform coordinate to new axis
            var transformed = Helper.MapPointsGlobal2Local(load.Value.ToArray(), axis);

            var direction = new string[3] {
                "X", "Y", "Z"
            };

            for (var i = 0; i < Math.Min(direction.Count(), load.Loading.Value.Count()); i++)
            {
                if (load.Loading.Value[i] == 0)
                {
                    continue;
                }

                var subLs = new List <string>();
                for (var j = 0; j < transformed.Count(); j += 3)
                {
                    subLs.Add("(" + transformed[j].ToString() + "," + transformed[j + 1].ToString() + ")");
                }

                ls.Clear();

                var index = Initialiser.AppResources.Cache.ResolveIndex(typeof(GSAGridLineLoad).GetGSAKeyword());

                var sid = Helper.GenerateSID(load);
                ls.AddRange(new[] {
                    "SET_AT",
                    index.ToString(),
                    keyword + (string.IsNullOrEmpty(sid) ? "" : ":" + sid),
                    load.Name == null || load.Name == "" ? " " : load.Name + (load.Name.All(char.IsDigit) ? " " : ""),
                    gridSurfaceIndex.ToString(),
                    "POLYGON",
                    string.Join(" ", subLs),
                    loadCaseRef.ToString(),
                    "GLOBAL",
                    "NO",
                    direction[i],
                    load.Loading.Value[i].ToString(),
                    load.LoadingEnd == null ? load.Loading.Value[i].ToString() : load.LoadingEnd.Value[i].ToString()
                });

                gwaCommands.Add(string.Join(Initialiser.AppResources.Proxy.GwaDelimiter.ToString(), ls));
            }

            return(string.Join("\n", gwaCommands));
        }
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }

            var mat = this.Value as StructuralMaterialConcrete;

            if (mat.ApplicationId == null)
            {
                return("");
            }

            var keyword = typeof(GSAMaterialConcrete).GetGSAKeyword();
            var index   = Initialiser.Cache.ResolveIndex(typeof(GSAMaterialConcrete).GetGSAKeyword(), mat.ApplicationId);

            // TODO: This function barely works.
            var ls = new List <string>
            {
                "SET",
                "MAT_CONCRETE.17" + ":" + Helper.GenerateSID(mat),
                index.ToString(),
                "MAT.8",
                mat.Name == null || mat.Name == "" ? " " : mat.Name,
                "YES",                                 // Unlocked
                (mat.YoungsModulus * 1000).ToString(), // E
                mat.PoissonsRatio.ToString(),          // nu
                mat.ShearModulus.ToString(),           // G
                mat.Density.ToString(),                // rho
                mat.CoeffThermalExpansion.ToString(),  // alpha
                "MAT_ANAL.1",
                "Concrete",
                "-268435456",                         // TODO: What is this?
                "MAT_ELAS_ISO",
                "6",                                  // TODO: What is this?
                mat.YoungsModulus.ToString(),         // E
                mat.PoissonsRatio.ToString(),         // nu
                mat.Density.ToString(),               // rho
                mat.CoeffThermalExpansion.ToString(), // alpha
                mat.ShearModulus.ToString(),          // G
                "0",                                  // TODO: What is this?
                "0",                                  // TODO: What is this?
                "0",                                  // TODO: What is this?
                "0",                                  // TODO: What is this?
                "0",                                  // TODO: What is this?
                "0",                                  // TODO: What is this?
                "0",                                  // TODO: What is this?
                "0",                                  // Ultimate strain
                "MAT_CURVE_PARAM.2",
                "",
                "UNDEF",
                "1", // Material factor on strength
                "1", // Material factor on elastic modulus
                "MAT_CURVE_PARAM.2",
                "",
                "UNDEF",
                "1",                                // Material factor on strength
                "1",                                // Material factor on elastic modulus
                "0",                                // Cost
                "CYLINDER",                         // Strength type
                "N",                                // Cement class
                mat.CompressiveStrength.ToString(), // Concrete strength
                "0",                                //ls.Add("27912500"); // Uncracked strength
                "0",                                //ls.Add("17500000"); // Cracked strength
                "0",                                //ls.Add("2366431"); // Tensile strength
                "0",                                //ls.Add("2366431"); // Peak strength for curves
                "0",                                // TODO: What is this?
                "1",                                // Ratio of initial elastic modulus to secant modulus
                "2",                                // Parabolic coefficient
                "0.00218389285990043",              // SLS strain at peak stress
                "0.0035",                           // SLS max strain
                "0.00041125",                       // ULS strain at plateau stress
                mat.MaxStrain.ToString(),           // ULS max compressive strain
                "0.0035",                           // TODO: What is this?
                "0.002",                            // Plateau strain
                "0.0035",                           // Max axial strain
                "NO",                               // Lightweight?
                mat.AggragateSize.ToString(),       // Aggragate size
                "0",                                // TODO: What is this?
                "1",                                // TODO: What is this?
                "0.8825",                           // Constant stress depth
                "0",                                // TODO: What is this?
                "0",                                // TODO: What is this?
                "0",                                // TODO: What is this?
                "0",                                // TODO: What is this?
                "0"                                 // TODO: What is this?
            };

            return(string.Join("\t", ls));
        }
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }

            var node = this.Value as StructuralNode;

            if (node.Value == null || node.Value.Count() != 3)
            {
                return("");
            }

            if (!node.Mass.HasValue || node.Mass == 0)
            {
                return("");
            }

            var keyword   = typeof(GSA0DElement).GetGSAKeyword();
            var index     = Initialiser.Cache.ResolveIndex(typeof(GSA0DElement).GetGSAKeyword(), node.ApplicationId);
            var propIndex = Initialiser.Cache.ResolveIndex("PROP_MASS.2", node.ApplicationId);
            var nodeIndex = Initialiser.Cache.ResolveIndex(typeof(GSANode).GetGSAKeyword(), node.ApplicationId);

            var gwaCommands = new List <string>();

            var ls = new List <string>
            {
                "SET",
                keyword + ":" + Helper.GenerateSID(node),
                index.ToString(),
                node.Name == null || node.Name == "" ? " " : node.Name,
                "NO_RGB",
                "MASS",
                propIndex.ToString(),
                "0",      // Group
                nodeIndex.ToString(),
                "0",      // Orient Node
                "0",      // Beta
                "NO_RLS", // Release
                "0",      // Offset x-start
                "0",      // Offset y-start
                "0",      // Offset y
                "0",      // Offset z
                ""        //Dummy
            };

            gwaCommands.Add(string.Join("\t", ls));

            ls = new List <string>
            {
                "SET",
                "PROP_MASS.2" + ":" + Helper.GenerateSID(node),
                propIndex.ToString(),
                "",
                "NO_RGB",
                "GLOBAL",
                node.Mass.ToString(),
                "0",
                "0",
                "0",
                "0",
                "0",
                "0",

                "MOD",
                "100%",
                "100%",
                "100%"
            };

            gwaCommands.Add(string.Join("\t", ls));

            return(string.Join("\n", gwaCommands));
        }
Exemplo n.º 21
0
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }

            var constraint = this.Value as StructuralRigidConstraints;

            if (constraint.Constraint == null)
            {
                return("");
            }

            var keyword = typeof(GSARigidConstraints).GetGSAKeyword();

            var index = Initialiser.Cache.ResolveIndex(keyword, constraint.ApplicationId);

            var slaveNodeIndices = Initialiser.Cache.LookupIndices(typeof(GSANode).GetGSAKeyword(), constraint.NodeRefs).Where(x => x.HasValue)
                                   .Distinct().OrderBy(i => i).Select(x => x.Value.ToString()).ToList();
            var slaveNodeIndicesSummary = slaveNodeIndices.Count > 0 ? string.Join(" ", slaveNodeIndices) : "none";
            var masterNodeIndex         = Initialiser.Cache.LookupIndex(typeof(GSANode).GetGSAKeyword(), constraint.MasterNodeRef);
            var stageDefRefs            = Initialiser.Cache.LookupIndices(typeof(GSAConstructionStage).GetGSAKeyword(), constraint.ConstructionStageRefs)
                                          .Where(x => x.HasValue).Distinct().Select(x => x.Value.ToString()).ToList();

            var subLs = new List <string>();

            if (constraint.Constraint.Value[0])
            {
                var x = "X:X";
                if (constraint.Constraint.Value[4])
                {
                    x += "YY";
                }
                if (constraint.Constraint.Value[5])
                {
                    x += "ZZ";
                }
                subLs.Add(x);
            }

            if (constraint.Constraint.Value[1])
            {
                var y = "Y:Y";
                if (constraint.Constraint.Value[3])
                {
                    y += "XX";
                }
                if (constraint.Constraint.Value[5])
                {
                    y += "ZZ";
                }
                subLs.Add(y);
            }

            if (constraint.Constraint.Value[2])
            {
                var z = "Z:Z";
                if (constraint.Constraint.Value[3])
                {
                    z += "XX";
                }
                if (constraint.Constraint.Value[4])
                {
                    z += "YY";
                }
                subLs.Add(z);
            }

            if (constraint.Constraint.Value[3])
            {
                subLs.Add("XX:XX");
            }

            if (constraint.Constraint.Value[4])
            {
                subLs.Add("YY:YY");
            }

            if (constraint.Constraint.Value[5])
            {
                subLs.Add("ZZ:ZZ");
            }

            var ls = new List <string>
            {
                "SET_AT",
                index.ToString(),
                keyword + ":" + Helper.GenerateSID(constraint),
                constraint.Name == null || constraint.Name == "" ? " " : constraint.Name,
                (masterNodeIndex.HasValue) ? masterNodeIndex.Value.ToString() : "0", // Master node
                string.Join("-", subLs),
                string.Join(" ", slaveNodeIndices),
                string.Join(" ", stageDefRefs),
                "0" // Parent member
            };

            return(string.Join("\t", ls));
        }
Exemplo n.º 22
0
        public string SetGWACommand(int group = 0)
        {
            if (this.Value == null)
            {
                return("");
            }

            var obj      = (SpeckleObject)this.Value;
            var baseMesh = (SpeckleMesh)this.Value;

            if (baseMesh.Vertices == null || baseMesh.Vertices.Count() == 0)
            {
                return("");
            }

            var colour = (baseMesh.Colors == null || baseMesh.Colors.Count < 1) ? "NO_RGB" : baseMesh.Colors[0].ArgbToHexColor().ToString();

            StructuralAxis          axis;
            Structural2DElementMesh mesh;
            bool?  gsaDummy;
            string propRef;
            double?offset;
            string sid;
            Structural2DElementType structural2dElementType;
            double?gsaMeshSize;

            //This is to avoid relying on the fact that this.Value is dynamic - casting to one of the expected types first
            if (this.Value is Structural2DElement)
            {
                var el = (Structural2DElement)this.Value;
                structural2dElementType = el.ElementType;
                sid     = Helper.GenerateSID(el);
                propRef = el.PropertyRef;
                mesh    = new Structural2DElementMesh()
                {
                    baseMesh = this.Value.baseMesh
                };
                gsaMeshSize = el.GSAMeshSize;
                gsaDummy    = el.GSADummy;
                axis        = el.Axis;
                offset      = el.Offset;
            }
            else if (this.Value is Structural2DElementMesh)
            {
                var el = (Structural2DElementMesh)this.Value;
                structural2dElementType = el.ElementType;
                propRef     = el.PropertyRef;
                sid         = Helper.GenerateSID(el);
                mesh        = this.Value;
                gsaMeshSize = el.GSAMeshSize;
                gsaDummy    = el.GSADummy;
                axis        = (el.Axis == null || el.Axis.Count == 0) ? null : el.Axis.First();
                offset      = (el.Offset == null || el.Offset.Count == 0) ? null : (double?)el.Offset.First();
            }
            else
            {
                return("");
            }

            var keyword = typeof(GSA2DMember).GetGSAKeyword();

            var index = Initialiser.Cache.ResolveIndex(typeof(GSA2DMember).GetGSAKeyword(), obj.ApplicationId);

            var propKeyword = typeof(GSA2DProperty).GetGSAKeyword();
            var indexResult = Initialiser.Cache.LookupIndex(propKeyword, propRef);
            //If the reference can't be found, then reserve a new index so that it at least doesn't point to any other existing record
            var propIndex = indexResult ?? Initialiser.Cache.ResolveIndex(propKeyword, propRef);

            if (indexResult == null && obj.ApplicationId != null)
            {
                if (propRef == null)
                {
                    Helper.SafeDisplay("Blank property references found for these Application IDs:", obj.ApplicationId);
                }
                else
                {
                    Helper.SafeDisplay("Property references not found:", obj.ApplicationId + " referencing " + propRef);
                }
            }

            var gwaCommands = new List <string>();

            var ls = new List <string>
            {
                "SET",
                keyword + ":" + sid,
                index.ToString(),
                string.IsNullOrEmpty(obj.Name) ? " " : obj.Name,
                colour
            };

            ls.Add(ElementTypeToString(structural2dElementType));
            ls.Add(propIndex.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();

            if (connectivities == null || connectivities.Count() == 0)
            {
                //This is likely if the vertices are duplicated or other strange states
                return("");
            }

            var coor = new List <double>();

            foreach (var c in connectivities[0])
            {
                coor.AddRange(baseMesh.Vertices.Skip(c * 3).Take(3));
                var currIndex = Helper.NodeAt(baseMesh.Vertices[c * 3], baseMesh.Vertices[c * 3 + 1], baseMesh.Vertices[c * 3 + 2], Initialiser.Settings.CoincidentNodeAllowance);
                if (prevNodeIndex != currIndex)
                {
                    topo += currIndex.ToString() + " ";
                }
                prevNodeIndex = currIndex;
            }
            ls.Add(topo.Trim());
            ls.Add("0"); // Orientation node
            if (axis == null)
            {
                ls.Add("0");
            }
            else
            {
                try
                {
                    ls.Add(Helper.Get2DAngle(coor.ToArray(), axis).ToString());
                }
                catch { ls.Add("0"); }
            }
            ls.Add(gsaMeshSize == 0 ? "1" : 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((gsaDummy.HasValue && gsaDummy.Value) ? "DUMMY" : "ACTIVE");
            ls.Add("NO");                                            // Internal auto offset
            ls.Add(offset.HasValue ? offset.ToString() : "0");       // Offset z
            ls.Add("ALL");                                           // Exposure

            gwaCommands.Add(string.Join("\t", ls));

            return(string.Join("\n", gwaCommands));
        }
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }

            var infl = this.Value as StructuralNodalInfluenceEffect;

            var keyword = typeof(GSANodalInfluenceEffect).GetGSAKeyword();

            var index = Initialiser.AppResources.Cache.ResolveIndex(typeof(GSANodalInfluenceEffect).GetGSAKeyword(), infl.ApplicationId);

            var nodeRef = Initialiser.AppResources.Cache.LookupIndex(typeof(GSANode).GetGSAKeyword(), infl.NodeRef);

            if (!nodeRef.HasValue)
            {
                return("");
            }

            var gwaCommands = new List <string>();

            Helper.SetAxis(infl.Axis, out var axisIndex, out var axisGwa, infl.Name);
            if (axisGwa.Length > 0)
            {
                gwaCommands.Add(axisGwa);
            }

            var direction = new string[6] {
                "X", "Y", "Z", "XX", "YY", "ZZ"
            };

            //This will cause multiple GWA lines to have the same application Id - might need a review
            var sid = Helper.GenerateSID(infl);

            for (var i = 0; i < infl.Directions.Value.Count(); i++)
            {
                var ls = new List <string>
                {
                    "SET_AT",
                    index.ToString(),
                    keyword + (string.IsNullOrEmpty(sid) ? "" : ":" + sid),
                    infl.Name == null || infl.Name == "" ? " " : infl.Name,
                    infl.GSAEffectGroup.ToString(),
                    nodeRef.Value.ToString(),
                    infl.Factor.ToString()
                };
                switch (infl.EffectType)
                {
                case StructuralInfluenceEffectType.Force:
                    ls.Add("FORCE");
                    break;

                case StructuralInfluenceEffectType.Displacement:
                    ls.Add("DISP");
                    break;

                default:
                    return("");
                }
                ls.Add(axisIndex.ToString());
                ls.Add(direction[i]);
                gwaCommands.Add(string.Join(Initialiser.AppResources.Proxy.GwaDelimiter.ToString(), ls));
            }
            return(string.Join("\n", gwaCommands));
        }
Exemplo n.º 24
0
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }

            var stageDef = this.Value as StructuralConstructionStage;

            var sourceType = stageDef.Type;

            var keyword = typeof(GSAConstructionStage).GetGSAKeyword();

            var index = Initialiser.Cache.ResolveIndex(typeof(GSAConstructionStage).GetGSAKeyword(), stageDef.ApplicationId);

            var targetString = " ";

            if (stageDef.ElementRefs != null && stageDef.ElementRefs.Count() > 0)
            {
                if (Initialiser.Settings.TargetLayer == GSATargetLayer.Analysis)
                {
                    var e1DIndices     = Initialiser.Cache.LookupIndices(typeof(GSA1DElement).GetGSAKeyword(), stageDef.ElementRefs).Where(x => x.HasValue).Select(x => x.Value).ToList();
                    var e1DPolyIndices = Initialiser.Cache.LookupIndices(typeof(GSA1DElementPolyline).GetGSAKeyword(), stageDef.ElementRefs).Where(x => x.HasValue).Select(x => x.Value).ToList();
                    var e2DIndices     = Initialiser.Cache.LookupIndices(typeof(GSA2DElement).GetGSAKeyword(), stageDef.ElementRefs).Where(x => x.HasValue).Select(x => x.Value).ToList();
                    var e2DMeshIndices = Initialiser.Cache.LookupIndices(typeof(GSA2DElementMesh).GetGSAKeyword(), stageDef.ElementRefs).Where(x => x.HasValue).Select(x => x.Value).ToList();

                    var indices = new List <int>(e1DIndices);
                    indices.AddRange(e1DPolyIndices);
                    indices.AddRange(e2DIndices);
                    indices.AddRange(e2DMeshIndices);
                    indices = indices.Distinct().ToList();

                    targetString = string.Join(" ", indices.Select(x => x.ToString()));
                }
                else if (Initialiser.Settings.TargetLayer == GSATargetLayer.Design)
                {
                    var m1DIndices = Initialiser.Cache.LookupIndices(typeof(GSA1DMember).GetGSAKeyword(), stageDef.ElementRefs).Where(x => x.HasValue).Select(x => x.Value).ToList();
                    var m2DIndices = Initialiser.Cache.LookupIndices(typeof(GSA2DMember).GetGSAKeyword(), stageDef.ElementRefs).Where(x => x.HasValue).Select(x => x.Value).ToList();

                    var indices = new List <int>(m1DIndices);
                    indices.AddRange(m2DIndices);
                    indices = indices.Distinct().ToList();

                    targetString = string.Join(" ", indices.Select(i => "G" + i.ToString()));
                }
            }

            var stageName = string.IsNullOrEmpty(stageDef.Name) ? " " : stageDef.Name;

            var ls = new List <string>
            {
                // Set ANAL_STAGE
                "SET",
                keyword + ":" + Helper.GenerateSID(stageDef),
                index.ToString(),
                stageName,                    // Name
                "NO_RGB",                     // Colour
                targetString,                 //Elements by group name
                "0",                          //Creep factor
                stageDef.StageDays.ToString() // Stage
            };

            return(string.Join("\t", ls));
        }
Exemplo n.º 25
0
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }

            var load = this.Value as Structural2DLoadPanel;

            if (load.ApplicationId == null)
            {
                return("");
            }

            var keyword = typeof(GSAGridAreaLoad).GetGSAKeyword();

            //There are no GSA types for these yet so use empty strings for the type names for the index
            var gridSurfaceIndex = Initialiser.Cache.ResolveIndex("GRID_SURFACE.1");
            var gridPlaneIndex   = Initialiser.Cache.ResolveIndex("GRID_PLANE.4");

            var loadCaseKeyword = typeof(GSALoadCase).GetGSAKeyword();
            var indexResult     = Initialiser.Cache.LookupIndex(loadCaseKeyword, load.LoadCaseRef);
            var loadCaseRef     = indexResult ?? Initialiser.Cache.ResolveIndex(loadCaseKeyword, load.LoadCaseRef);

            if (indexResult == null && load.ApplicationId != null)
            {
                if (load.LoadCaseRef == null)
                {
                    Helper.SafeDisplay("Blank load case references found for these Application IDs:", load.ApplicationId);
                }
                else
                {
                    Helper.SafeDisplay("Load case references not found:", load.ApplicationId + " referencing " + load.LoadCaseRef);
                }
            }
            if (load.Loading == null || load.Loading.Value == null || load.Loading.Value.Count() == 0)
            {
                Helper.SafeDisplay("Grid area loads not added to model due to empty loading found:", load.ApplicationId);
                return("");
            }

            var axis = Helper.Parse2DAxis(load.Value.ToArray());

            // Calculate elevation
            var elevation = (load.Value[0] * axis.Normal.Value[0] +
                             load.Value[1] * axis.Normal.Value[1] +
                             load.Value[2] * axis.Normal.Value[2]) /
                            Math.Sqrt(axis.Normal.Value[0] * axis.Normal.Value[0] +
                                      axis.Normal.Value[1] * axis.Normal.Value[1] +
                                      axis.Normal.Value[2] * axis.Normal.Value[2]);

            // Transform coordinate to new axis
            var transformed = Helper.MapPointsGlobal2Local(load.Value.ToArray(), axis);

            var ls = new List <string>();

            var direction = new string[3] {
                "X", "Y", "Z"
            };

            var gwaCommands = new List <string>();


            Helper.SetAxis(axis, out int planeAxisIndex, out string planeAxisGwa, load.Name);
            if (planeAxisGwa.Length > 0)
            {
                gwaCommands.Add(planeAxisGwa);
            }

            ls.AddRange(new[] {
                "SET",
                "GRID_PLANE.4",
                gridPlaneIndex.ToString(),
                load.Name == null || load.Name == "" ? " " : load.Name,
                "GENERAL", // Type
                planeAxisIndex.ToString(),
                elevation.ToString(),
                "0", // Elevation above
                "0"
            });      // Elevation below
            gwaCommands.Add(string.Join("\t", ls));

            ls.Clear();
            ls.AddRange(new[] {
                "SET",
                "GRID_SURFACE.1",
                gridSurfaceIndex.ToString(),
                load.Name == null || load.Name == "" ? " " : load.Name,
                gridPlaneIndex.ToString(),
                "2",    // Dimension of elements to target
                "all",  // List of elements to target
                "0.01", // Tolerance
                "ONE",  // Span option
                "0"
            });         // Span angle
            gwaCommands.Add(string.Join("\t", ls));

            for (var i = 0; i < load.Loading.Value.Count(); i++)
            {
                if (load.Loading.Value[i] == 0)
                {
                    continue;
                }

                var index = Initialiser.Cache.ResolveIndex(typeof(GSAGridAreaLoad).GetGSAKeyword());

                ls.Clear();
                var subLs = new List <string>();
                for (var j = 0; j < transformed.Count(); j += 3)
                {
                    //The GWA that GSA generates seems to return a rounded number, so do so here
                    subLs.Add("(" + Math.Round(transformed[j], 4).ToString() + "," + Math.Round(transformed[j + 1], 4).ToString() + ")");
                }

                ls.AddRange(new string[] {
                    "SET_AT",
                    index.ToString(),
                    keyword + ":" + Helper.GenerateSID(load),
                    load.Name == null || load.Name == "" ? " " : load.Name,
                    gridSurfaceIndex.ToString(),
                    "POLYGON",
                    "\"" + string.Join(" ", subLs) + "(m)\"",
                    loadCaseRef.ToString(),
                    "GLOBAL",
                    "NO",
                    direction[i],
                    load.Loading.Value[i].ToString()
                });

                gwaCommands.Add(string.Join("\t", ls));
            }

            return(string.Join("\n", gwaCommands));
        }
    public string SetGWACommand(int group = 0)
    {
      if (this.Value == null)
      { 
        return "";
      }

      var mesh = this.Value as Structural2DElement;
      if (mesh.ApplicationId == null)
      {
        return "";
      }

      var keyword = typeof(GSA2DElement).GetGSAKeyword();

      var index = Initialiser.AppResources.Cache.ResolveIndex(typeof(GSA2DElement).GetGSAKeyword(), mesh.ApplicationId);

      var propKeyword = typeof(GSA2DProperty).GetGSAKeyword();
      var indexResult = Initialiser.AppResources.Cache.LookupIndex(propKeyword, mesh.PropertyRef);
      //If the reference can't be found, then reserve a new index so that it at least doesn't point to any other existing record
      var propRef = indexResult ?? Initialiser.AppResources.Cache.ResolveIndex(propKeyword, mesh.PropertyRef);
      if (indexResult == null && mesh.ApplicationId != null)
      {
        if (mesh.PropertyRef == null)
        {
          Helper.SafeDisplay("Blank property references found for these Application IDs:", mesh.ApplicationId);
        }
        else
        {
          Helper.SafeDisplay("2D property references not found:", mesh.ApplicationId + " referencing " + mesh.PropertyRef);
        }
      }

      var sid = Helper.GenerateSID(mesh);
      var ls = new List<string>
      {
        "SET",
        keyword + (string.IsNullOrEmpty(sid) ? "" : ":" + sid),
        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(Initialiser.AppResources.Proxy.NodeAt(mesh.Vertices[mesh.Faces[i] * 3], mesh.Vertices[mesh.Faces[i] * 3 + 1], mesh.Vertices[mesh.Faces[i] * 3 + 2], Initialiser.AppResources.Settings.CoincidentNodeAllowance).ToString());
      }
      ls.Add("0"); //Orientation node
      if (mesh.Axis == null)
      {
        ls.Add("0");
      }
      else
      {
        try
        {
          ls.Add(Helper.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(""); // parent_member

      ls.Add((mesh.GSADummy.HasValue && mesh.GSADummy.Value) ? "DUMMY" : "");

      return (string.Join(Initialiser.AppResources.Proxy.GwaDelimiter.ToString(), ls));
    }
    public string SetGWACommand(int group = 0)
    {
      if (this.Value == null)
        return "";

      var obj = (SpeckleObject)this.Value;
      var baseMesh = (SpeckleMesh)this.Value;

      if (baseMesh.Vertices == null || baseMesh.Vertices.Count() == 0)
        return "";

      var colour = (baseMesh.Colors == null || baseMesh.Colors.Count < 1) ? "NO_RGB" : baseMesh.Colors[0].ArgbToHexColor().ToString();

      StructuralAxis axis;
      Structural2DElementMesh mesh;
      bool? gsaDummy;
      string propRef;
      double? offset;
      string sid;
      Structural2DElementType structural2dElementType;
      double? gsaMeshSize;

      //This is to avoid relying on the fact that this.Value is dynamic - casting to one of the expected types first
      if (this.Value is Structural2DElement)
      {
        var el = (Structural2DElement)this.Value;
        structural2dElementType = el.ElementType;
        sid = Helper.GenerateSID(el);
        propRef = el.PropertyRef;
        mesh = new Structural2DElementMesh() { baseMesh = ((Structural2DElement) this.Value).baseMesh };
        gsaMeshSize = el.GSAMeshSize;
        gsaDummy = el.GSADummy;
        axis = el.Axis;
        offset = el.Offset;
      }
      else if (this.Value is Structural2DElementMesh)
      {
        var el = (Structural2DElementMesh)this.Value;
        structural2dElementType = el.ElementType;
        propRef = el.PropertyRef;
        sid = Helper.GenerateSID(el);
        mesh = ((Structural2DElementMesh) this.Value);
        gsaMeshSize = el.GSAMeshSize;
        gsaDummy = el.GSADummy;
        axis = (el.Axis == null || el.Axis.Count == 0) ? null : el.Axis.First();
        offset = (el.Offset == null || el.Offset.Count == 0) ? null : (double ?) el.Offset.First();
      }
      else
      {
        return "";
      }

      var keyword = typeof(GSA2DMember).GetGSAKeyword();

      var index = Initialiser.AppResources.Cache.ResolveIndex(typeof(GSA2DMember).GetGSAKeyword(), obj.ApplicationId);

      var propKeyword = typeof(GSA2DProperty).GetGSAKeyword();
      var indexResult = Initialiser.AppResources.Cache.LookupIndex(propKeyword, propRef);
      //If the reference can't be found, then reserve a new index so that it at least doesn't point to any other existing record
      var propIndex = indexResult ?? Initialiser.AppResources.Cache.ResolveIndex(propKeyword, propRef);
      if (indexResult == null && obj.ApplicationId != null)
      {
        if (propRef == null)
        {
          Helper.SafeDisplay("Blank property references found for these Application IDs:", obj.ApplicationId);
        }
        else
        {
          Helper.SafeDisplay("2D property references not found:", obj.ApplicationId + " referencing " + propRef);
        }
      }

      var gwaCommands = new List<string>();

      var ls = new List<string>
      {
        "SET",
        keyword + ":" + sid,
        index.ToString(),
        string.IsNullOrEmpty(obj.Name) ? " " : obj.Name,
        colour
      };
      ls.Add(ElementTypeToString(structural2dElementType));
      ls.Add("ALL");
      ls.Add(propIndex.ToString());
      ls.Add(group != 0 ? group.ToString() : index.ToString()); // TODO: This allows for targeting of elements from members group
      
      mesh.Consolidate();
      var connectivities = mesh.Edges();

      if (connectivities == null || connectivities.Count() == 0)
      {
        //This is likely if the vertices are duplicated or other strange states
        return "";
      }

      var coor = new List<double>();
      foreach (var c in connectivities[0])
      {
        coor.AddRange(baseMesh.Vertices.Skip(c * 3).Take(3));
      }
      coor = coor.Essential().ToList();
      var coorPts = Enumerable.Range(0, coor.Count() / 3).Select(i => new double[] { coor[i * 3], coor[i * 3 + 1], coor[i * 3 + 2] }).ToList();

      //Use these reduced coordinates to call NodeAt and create a topo string
      // topo
      var topo = "";
      var prevNodeIndex = -1;
      foreach (var coorPt in coorPts)
      {
        var currIndex = Initialiser.AppResources.Proxy.NodeAt(coorPt[0], coorPt[1], coorPt[2], Initialiser.AppResources.Settings.CoincidentNodeAllowance);
        if (prevNodeIndex != currIndex)
        {
          topo += currIndex.ToString() + " ";
        }
        prevNodeIndex = currIndex;
      }

      ls.Add(topo.Trim());
      
      ls.Add("0"); // Orientation node
      
      // angle
      if (axis == null)
      {
        ls.Add("0");
      }
      else
      {
        try
        {
          ls.Add(Helper.Get2DAngle(coor.ToArray(), axis).ToString());
        }
        catch { ls.Add("0"); }
      }
      ls.Add(gsaMeshSize == 0 ? "1" : gsaMeshSize.ToString()); // Target mesh size
      ls.Add("YES"); // intersector
      ls.Add("LINEAR"); // Element type
      ls.Add("0"); // Fire resistance (mins)
      ls.Add("0"); // Fire limiting temp
      ls.Add("0"); // Time 1
      ls.Add("0"); // Time 2
      ls.Add("0"); // Time 3
      ls.Add("0"); // Time 4
      ls.Add((gsaDummy.HasValue && gsaDummy.Value) ? "DUMMY" : "ACTIVE");
      ls.Add(offset.HasValue ? offset.ToString() : "0"); // Offset z
      ls.Add("NO"); // Internal auto offset
      //These are default values - filled in here to avoid instances of GWA comparisons (when upserting into the cache) showing change where there isn't
      ls.Add("REBAR_2D.1");
      ls.Add("0.03");
      ls.Add("0.03");
      ls.Add("0");
      gwaCommands.Add(string.Join(Initialiser.AppResources.Proxy.GwaDelimiter.ToString(), ls));

      return string.Join("\n", gwaCommands);
    }
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }
            var v = this.Value as Structural2DVoid;

            if (v.Vertices == null || v.Vertices.Count() == 0)
            {
                return("");
            }
            var keyword = typeof(GSA2DVoid).GetGSAKeyword();

            var index = Initialiser.AppResources.Cache.ResolveIndex(keyword, v.ApplicationId);

            var sid = Helper.GenerateSID(v);
            var ls  = new List <string>
            {
                "SET",
                keyword + (string.IsNullOrEmpty(sid) ? "" : ":" + sid),
                index.ToString(),
                v.Name == null || v.Name == "" ? " " : v.Name,
                v.Colors == null || v.Colors.Count() < 1 ? "NO_RGB" : v.Colors[0].ArgbToHexColor().ToString(),
                "2D_VOID_CUTTER",
                "ALL", // exposure
                "1",   // Property reference
                "0"    // Group
            };


            var prevNodeIndex = -1;

            // topo
            var topoIndices = new List <int>();

            if (v.Faces != null && v.Faces.Count() > 0)
            {
                var connectivities = v.Edges();
                foreach (var c in connectivities[0])
                {
                    var currIndex = Initialiser.AppResources.Proxy.NodeAt(v.Vertices[c * 3], v.Vertices[c * 3 + 1], v.Vertices[c * 3 + 2], Initialiser.AppResources.Settings.CoincidentNodeAllowance);
                    if (prevNodeIndex != currIndex)
                    {
                        topoIndices.Add(currIndex);
                    }
                    prevNodeIndex = currIndex;
                }
            }
            else
            {
                //Even if something has gone wrong in the generation of the faces (and therefore edges) of the mesh, if there are exactly 3 or 4 points,
                //assume that it is planar and create a void.
                //TO DO: review why the generation of faces results in an empty list for wall voids in the ToSpeckle() code.  Once that has been fixed,
                //the block below can be removed
                if (v.Vertices != null && (v.Vertices.Count() == 9 || v.Vertices.Count() == 12))
                {
                    int numVertices = v.Vertices.Count() / 3;
                    for (var i = 0; i < numVertices; i++)
                    {
                        var currIndex = Initialiser.AppResources.Proxy.NodeAt(v.Vertices[i * 3], v.Vertices[i * 3 + 1], v.Vertices[i * 3 + 2], Initialiser.AppResources.Settings.CoincidentNodeAllowance);
                        if (prevNodeIndex != currIndex)
                        {
                            topoIndices.Add(currIndex);
                        }
                        prevNodeIndex = currIndex;
                    }
                }
                else
                {
                    return("");
                }
            }

            ls.Add(string.Join(" ", topoIndices));

            ls.Add("0"); // Orientation node
            ls.Add("0"); // Angles
            // Target mesh size
            if (Initialiser.AppResources.Proxy.GetUnits() == "mm")
            {
                ls.Add("1000");
            }
            else if (Initialiser.AppResources.Proxy.GetUnits() == "in")
            {
                ls.Add("39.3701");
            }
            else
            {
                ls.Add("1");
            }
            ls.Add("YES");    // intersector
            ls.Add("LINEAR"); // Element type
            ls.Add("0");      // Fire resistance (mins)
            ls.Add("0");      // Fire limiting temp
            ls.Add("0");      // Time 1
            ls.Add("0");      // Time 2
            ls.Add("0");      // Time 3
            ls.Add("0");      // Time 4
            ls.Add("ACTIVE"); // Dummy
            ls.Add("0");      // Offset z
            ls.Add("NO");     // Internal auto offset
            //These are default values - filled in here to avoid instances of GWA comparisons (when upserting into the cache) showing change where there isn't
            ls.Add("REBAR_2D.1");
            if (Initialiser.AppResources.Proxy.GetUnits() == "mm")
            {
                ls.Add("30");
                ls.Add("30");
            }
            else if (Initialiser.AppResources.Proxy.GetUnits() == "in")
            {
                ls.Add("1");
                ls.Add("1");
            }
            else
            {
                ls.Add("0.03");
                ls.Add("0.03");
            }
            ls.Add("0");
            return(string.Join(Initialiser.AppResources.Proxy.GwaDelimiter.ToString(), ls));
        }
        public string SetGWACommand(string keyword)
        {
            if (this.Value == null)
            {
                return("");
            }

            var load = this.Value as Structural1DLoad;

            if (load.Loading == null)
            {
                return("");
            }

            List <int> elementRefs;
            List <int> groupRefs;

            if (Initialiser.Settings.TargetLayer == GSATargetLayer.Analysis)
            {
                elementRefs = Initialiser.Cache.LookupIndices(typeof(GSA1DElement).GetGSAKeyword(), load.ElementRefs).Where(x => x.HasValue).Select(x => x.Value).ToList();
                groupRefs   = Initialiser.Cache.LookupIndices(typeof(GSA1DElementPolyline).GetGSAKeyword(), load.ElementRefs).Where(x => x.HasValue).Select(x => x.Value).ToList();
            }
            else if (Initialiser.Settings.TargetLayer == GSATargetLayer.Design)
            {
                elementRefs = new List <int>();
                groupRefs   = Initialiser.Cache.LookupIndices(typeof(GSA1DMember).GetGSAKeyword(), load.ElementRefs).Where(x => x.HasValue).Select(x => x.Value).ToList();
                groupRefs.AddRange(Initialiser.Cache.LookupIndices(typeof(GSA1DElementPolyline).GetGSAKeyword(), load.ElementRefs).Where(x => x.HasValue).Select(x => x.Value).ToList());
            }
            else
            {
                return("");
            }

            var loadCaseKeyword = typeof(GSALoadCase).GetGSAKeyword();
            var indexResult     = Initialiser.Cache.LookupIndex(loadCaseKeyword, load.LoadCaseRef);
            var loadCaseRef     = indexResult ?? Initialiser.Cache.ResolveIndex(loadCaseKeyword, load.LoadCaseRef);

            if (indexResult == null && load.ApplicationId != null)
            {
                if (load.LoadCaseRef == null)
                {
                    Helper.SafeDisplay("Blank load case references found for these Application IDs:", load.ApplicationId);
                }
                else
                {
                    Helper.SafeDisplay("Load case references not found:", load.ApplicationId + " referencing " + load.LoadCaseRef);
                }
            }

            var direction = new string[6] {
                "X", "Y", "Z", "XX", "YY", "ZZ"
            };

            var gwaCommands = new List <string>();

            for (var i = 0; i < load.Loading.Value.Count(); i++)
            {
                var ls = new List <string>();

                if (load.Loading.Value[i] == 0)
                {
                    continue;
                }

                var index = Initialiser.Cache.ResolveIndex(keyword);

                ls.Add("SET_AT");
                ls.Add(index.ToString());
                ls.Add("LOAD_BEAM_UDL" + ":" + Helper.GenerateSID(load)); // TODO: Only writes to UDL load
                ls.Add(load.Name == null || load.Name == "" ? " " : load.Name);
                // TODO: This is a hack.
                ls.Add(string.Join(" ", elementRefs.Select(x => x.ToString()).Concat(groupRefs.Select(x => "G" + x.ToString())).OrderBy(e => e)));
                ls.Add(loadCaseRef.ToString());
                ls.Add("GLOBAL"); // Axis
                ls.Add("NO");     // Projected
                ls.Add(direction[i]);
                ls.Add(load.Loading.Value[i].ToString());

                gwaCommands.Add(string.Join("\t", ls));
            }

            return(string.Join("\n", gwaCommands));
        }
        public string SetGWACommand()
        {
            if (this.Value == null)
            {
                return("");
            }

            var load = this.Value as Structural2DThermalLoad;

            if (load.ApplicationId == null)
            {
                return("");
            }

            var keyword = typeof(GSA2DThermalLoading).GetGSAKeyword();

            var index = Initialiser.Cache.ResolveIndex(typeof(GSA2DThermalLoading).GetGSAKeyword(), load.ApplicationId);

            var targetString = " ";

            if (load.ElementRefs != null && load.ElementRefs.Count() > 0)
            {
                if (Initialiser.Settings.TargetLayer == GSATargetLayer.Analysis)
                {
                    var e2DIndices     = Initialiser.Cache.LookupIndices(typeof(GSA2DElement).GetGSAKeyword(), load.ElementRefs).Where(x => x.HasValue).Select(x => x.Value).ToList();
                    var e2DMeshIndices = Initialiser.Cache.LookupIndices(typeof(GSA2DElementMesh).GetGSAKeyword(), load.ElementRefs).Where(x => x.HasValue).Select(x => x.Value).ToList();
                    targetString = string.Join(" ",
                                               e2DIndices.Select(x => x.ToString())
                                               .Concat(e2DMeshIndices.Select(x => "G" + x.ToString())).OrderBy(i => i));
                }
                else if (Initialiser.Settings.TargetLayer == GSATargetLayer.Design)
                {
                    var m2DIndices = Initialiser.Cache.LookupIndices(typeof(GSA2DMember).GetGSAKeyword(), load.ElementRefs).Where(x => x.HasValue).Select(x => x.Value).ToList();
                    targetString = string.Join(" ",
                                               m2DIndices.Select(x => "G" + x.ToString()).OrderBy(i => i));
                }
            }

            var loadCaseKeyword = typeof(GSALoadCase).GetGSAKeyword();
            var indexResult     = Initialiser.Cache.LookupIndex(loadCaseKeyword, load.LoadCaseRef);
            var loadCaseRef     = indexResult ?? Initialiser.Cache.ResolveIndex(loadCaseKeyword, load.LoadCaseRef);

            if (indexResult == null && load.ApplicationId != null)
            {
                if (load.LoadCaseRef == null)
                {
                    Helper.SafeDisplay("Blank load case references found for these Application IDs:", load.ApplicationId);
                }
                else
                {
                    Helper.SafeDisplay("Load case references not found:", load.ApplicationId + " referencing " + load.LoadCaseRef);
                }
            }

            var loadingName = string.IsNullOrEmpty(load.Name) ? " " : load.Name;

            var ls = new List <string>
            {
                "SET_AT",
                index.ToString(),
                keyword + ":" + Helper.GenerateSID(load),
                loadingName,  // Name
                targetString, //Elements
                loadCaseRef.ToString(),
            };

            if (load.TopTemperature == load.BottomTemperature)
            {
                ls.Add("CONS");
                ls.Add(load.TopTemperature.ToString());
            }
            else
            {
                ls.Add("DZ");
                ls.Add(load.TopTemperature.ToString());
                ls.Add(load.BottomTemperature.ToString());
            }

            return(string.Join("\t", ls));
        }