public static string ToNative(this StructuralLoadCase loadCase)
        {
            if (string.IsNullOrEmpty(loadCase.ApplicationId))
            {
                return("");
            }
            return(Helper.ToNativeTryCatch(loadCase, () =>
            {
                var keyword = GsaRecord.GetKeyword <GsaLoadCase>();
                var index = Initialiser.AppResources.Cache.ResolveIndex(keyword, loadCase.ApplicationId);
                var streamId = Initialiser.AppResources.Cache.LookupStream(loadCase.ApplicationId);
                var gsaLoad = new GsaLoadCase()
                {
                    ApplicationId = loadCase.ApplicationId,
                    Index = index,
                    StreamId = streamId,
                    Title = loadCase.Name,
                    CaseType = loadCase.CaseType
                };

                if (gsaLoad.Gwa(out var gwaLines, false))
                {
                    Initialiser.AppResources.Cache.Upsert(keyword, index, gwaLines.First(), streamId, loadCase.ApplicationId, GsaRecord.GetGwaSetCommandType <GsaLoadCase>());
                }
                //TO DO: add to error messages shown on UI
                return "";
            }
 public static string ToNative(this StructuralLoadCase load)
 {
     return(new GSALoadCase()
     {
         Value = load
     }.SetGWACommand());
 }
        public void ParseGWACommand()
        {
            if (this.GWACommand == null)
            {
                return;
            }

            var obj = new StructuralLoadCase();

            var pieces = this.GWACommand.ListSplit("\t");

            var counter = 1; // Skip identifier

            this.GSAId        = Convert.ToInt32(pieces[counter++]);
            obj.ApplicationId = HelperClass.GetApplicationId(this.GetGSAKeyword(), this.GSAId);
            obj.Name          = pieces[counter++];

            var type = pieces[counter++];

            switch (type)
            {
            case "DEAD":
                obj.CaseType = StructuralLoadCaseType.Dead;
                break;

            case "LC_VAR_IMP":
                obj.CaseType = StructuralLoadCaseType.Live;
                break;

            case "WIND":
                obj.CaseType = StructuralLoadCaseType.Wind;
                break;

            case "SNOW":
                obj.CaseType = StructuralLoadCaseType.Snow;
                break;

            case "SEISMIC":
                obj.CaseType = StructuralLoadCaseType.Earthquake;
                break;

            case "LC_PERM_SOIL":
                obj.CaseType = StructuralLoadCaseType.Soil;
                break;

            case "LC_VAR_TEMP":
                obj.CaseType = StructuralLoadCaseType.Thermal;
                break;

            default:
                obj.CaseType = StructuralLoadCaseType.Generic;
                break;
            }

            // Rest is unimportant

            this.Value = obj;
        }
Exemplo n.º 4
0
        public static List <SpeckleObject> ToSpeckle(this AreaLoad myAreaLoad)
        {
            var polylines = new List <double[]>();

            var loops = myAreaLoad.GetLoops();

            foreach (var loop in loops)
            {
                var coor = new List <double>();
                foreach (var curve in loop)
                {
                    var points = curve.Tessellate();

                    foreach (var p in points.Skip(1))
                    {
                        coor.Add(p.X / Scale);
                        coor.Add(p.Y / Scale);
                        coor.Add(p.Z / Scale);
                    }
                }

                polylines.Add(coor.ToArray());

                // Only get outer loop
                break;
            }

            var forces = new StructuralVectorThree(new double[3]);

            forces.Value[0] = myAreaLoad.ForceVector1.X;
            forces.Value[1] = myAreaLoad.ForceVector1.Y;
            forces.Value[2] = myAreaLoad.ForceVector1.Z;

            if (myAreaLoad.OrientTo == LoadOrientTo.HostLocalCoordinateSystem)
            {
                var hostTransform = myAreaLoad.HostElement.GetLocalCoordinateSystem();

                var b0 = hostTransform.get_Basis(0);
                var b1 = hostTransform.get_Basis(1);
                var b2 = hostTransform.get_Basis(2);

                var fx = forces.Value[0] * b0.X + forces.Value[1] * b1.X + forces.Value[2] * b2.X;
                var fy = forces.Value[0] * b0.Y + forces.Value[1] * b1.Y + forces.Value[2] * b2.Y;
                var fz = forces.Value[0] * b0.Z + forces.Value[1] * b1.Z + forces.Value[2] * b2.Z;

                forces = new StructuralVectorThree(new double[] { fx, fy, fz });
            }
            else if (myAreaLoad.OrientTo == LoadOrientTo.WorkPlane)
            {
                var workPlane = ((SketchPlane)Doc.GetElement(myAreaLoad.WorkPlaneId)).GetPlane();

                var b0 = workPlane.XVec;
                var b1 = workPlane.YVec;
                var b2 = workPlane.Normal;

                var fx = forces.Value[0] * b0.X + forces.Value[1] * b1.X + forces.Value[2] * b2.X;
                var fy = forces.Value[0] * b0.Y + forces.Value[1] * b1.Y + forces.Value[2] * b2.Y;
                var fz = forces.Value[0] * b0.Z + forces.Value[1] * b1.Z + forces.Value[2] * b2.Z;

                forces = new StructuralVectorThree(new double[] { fx, fy, fz });
            }

            var myLoadCase = new StructuralLoadCase();

            myLoadCase.Name          = myAreaLoad.LoadCaseName;
            myLoadCase.ApplicationId = myAreaLoad.LoadCase.UniqueId;
            switch (myAreaLoad.LoadCategoryName)
            {
            case "Dead Loads":
                myLoadCase.CaseType = StructuralLoadCaseType.Dead;
                break;

            case "Live Loads":
                myLoadCase.CaseType = StructuralLoadCaseType.Live;
                break;

            case "Seismic Loads":
                myLoadCase.CaseType = StructuralLoadCaseType.Earthquake;
                break;

            case "Snow Loads":
                myLoadCase.CaseType = StructuralLoadCaseType.Snow;
                break;

            case "Wind Loads":
                myLoadCase.CaseType = StructuralLoadCaseType.Wind;
                break;

            default:
                myLoadCase.CaseType = StructuralLoadCaseType.Generic;
                break;
            }

            var myLoads = new List <SpeckleObject>();

            var counter = 0;

            foreach (var vals in polylines)
            {
                var myLoad = new Structural2DLoadPanel();
                myLoad.Name        = myAreaLoad.Name;
                myLoad.Value       = vals.ToList();
                myLoad.Loading     = forces;
                myLoad.LoadCaseRef = myLoadCase.ApplicationId;
                myLoad.Closed      = true;

                myLoad.ApplicationId = myAreaLoad.UniqueId + "_" + (counter++).ToString();

                myLoads.Add(myLoad);
            }

            return(myLoads.Concat(new List <SpeckleObject>()
            {
                myLoadCase
            }).ToList());
        }
Exemplo n.º 5
0
        public static List <SpeckleObject> ToSpeckle(this LineLoad myLineLoad)
        {
            var myLoad = new Structural1DLoadLine
            {
                Name = myLineLoad.Name
            };

            var points = myLineLoad.GetCurve().Tessellate();

            myLoad.Value = new List <double>();

            foreach (var p in points)
            {
                myLoad.Value.Add(p.X / Scale);
                myLoad.Value.Add(p.Y / Scale);
                myLoad.Value.Add(p.Z / Scale);
            }

            var forces = new StructuralVectorSix(new double[6]);

            forces.Value[0] = (myLineLoad.ForceVector1.X + myLineLoad.ForceVector2.X) / 2;
            forces.Value[1] = (myLineLoad.ForceVector1.Y + myLineLoad.ForceVector2.Y) / 2;
            forces.Value[2] = (myLineLoad.ForceVector1.Z + myLineLoad.ForceVector2.Z) / 2;
            forces.Value[3] = (myLineLoad.MomentVector1.X + myLineLoad.MomentVector2.X) / 2;
            forces.Value[4] = (myLineLoad.MomentVector1.Y + myLineLoad.MomentVector2.Y) / 2;
            forces.Value[5] = (myLineLoad.MomentVector1.Z + myLineLoad.MomentVector2.Z) / 2;

            if (myLineLoad.OrientTo == LoadOrientTo.HostLocalCoordinateSystem)
            {
                var hostTransform = myLineLoad.HostElement.GetLocalCoordinateSystem();

                var b0 = hostTransform.get_Basis(0);
                var b1 = hostTransform.get_Basis(1);
                var b2 = hostTransform.get_Basis(2);

                var fx = forces.Value[0] * b0.X + forces.Value[1] * b1.X + forces.Value[2] * b2.X;
                var fy = forces.Value[0] * b0.Y + forces.Value[1] * b1.Y + forces.Value[2] * b2.Y;
                var fz = forces.Value[0] * b0.Z + forces.Value[1] * b1.Z + forces.Value[2] * b2.Z;
                var mx = forces.Value[3] * b0.X + forces.Value[4] * b1.X + forces.Value[5] * b2.X;
                var my = forces.Value[3] * b0.Y + forces.Value[4] * b1.Y + forces.Value[5] * b2.Y;
                var mz = forces.Value[3] * b0.Z + forces.Value[4] * b1.Z + forces.Value[5] * b2.Z;

                forces = new StructuralVectorSix(new double[] { fx, fy, fz, mx, my, mz });
            }
            else if (myLineLoad.OrientTo == LoadOrientTo.WorkPlane)
            {
                var workPlane = ((SketchPlane)Doc.GetElement(myLineLoad.WorkPlaneId)).GetPlane();

                var b0 = workPlane.XVec;
                var b1 = workPlane.YVec;
                var b2 = workPlane.Normal;

                var fx = forces.Value[0] * b0.X + forces.Value[1] * b1.X + forces.Value[2] * b2.X;
                var fy = forces.Value[0] * b0.Y + forces.Value[1] * b1.Y + forces.Value[2] * b2.Y;
                var fz = forces.Value[0] * b0.Z + forces.Value[1] * b1.Z + forces.Value[2] * b2.Z;
                var mx = forces.Value[3] * b0.X + forces.Value[4] * b1.X + forces.Value[5] * b2.X;
                var my = forces.Value[3] * b0.Y + forces.Value[4] * b1.Y + forces.Value[5] * b2.Y;
                var mz = forces.Value[3] * b0.Z + forces.Value[4] * b1.Z + forces.Value[5] * b2.Z;

                forces = new StructuralVectorSix(new double[] { fx, fy, fz, mx, my, mz });
            }

            myLoad.Loading = forces;

            var myLoadCase = new StructuralLoadCase
            {
                Name          = myLineLoad.LoadCaseName,
                ApplicationId = myLineLoad.LoadCase.UniqueId
            };

            switch (myLineLoad.LoadCategoryName)
            {
            case "Dead Loads":
                myLoadCase.CaseType = StructuralLoadCaseType.Dead;
                break;

            case "Live Loads":
                myLoadCase.CaseType = StructuralLoadCaseType.Live;
                break;

            case "Seismic Loads":
                myLoadCase.CaseType = StructuralLoadCaseType.Earthquake;
                break;

            case "Snow Loads":
                myLoadCase.CaseType = StructuralLoadCaseType.Snow;
                break;

            case "Wind Loads":
                myLoadCase.CaseType = StructuralLoadCaseType.Wind;
                break;

            default:
                myLoadCase.CaseType = StructuralLoadCaseType.Generic;
                break;
            }

            myLoad.LoadCaseRef   = myLoadCase.ApplicationId;
            myLoad.ApplicationId = myLineLoad.UniqueId;

            return(new List <SpeckleObject>()
            {
                myLoad, myLoadCase
            });
        }