public static string ToNative(this Structural1DLoadLine load)
 {
     return(new GSAGridLineLoad()
     {
         Value = load
     }.SetGWACommand());
 }
Exemple #2
0
 public static string ToNative(this Structural1DLoadLine load)
 {
     return(SchemaConversion.Helper.ToNativeTryCatch(load, () => new GSAGridLineLoad()
     {
         Value = load
     }.SetGWACommand()));
 }
        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
            });
        }
Exemple #4
0
        public void ParseGWACommand()
        {
            if (this.GWACommand == null)
            {
                return;
            }

            var obj = new Structural1DLoadLine();

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

            var counter = 1; // Skip identifier

            obj.Name = pieces[counter++].Trim(new char[] { '"' });
            Helper.GetGridPlaneRef(Convert.ToInt32(pieces[counter++]), out int gridPlaneRefRet, out string gridSurfaceRec);
            Helper.GetGridPlaneData(gridPlaneRefRet, out int gridPlaneAxis, out double gridPlaneElevation, out string gridPlaneRec);
            this.SubGWACommand.Add(gridSurfaceRec);
            this.SubGWACommand.Add(gridPlaneRec);

            string gwaRec = null;
            var    axis   = Helper.Parse0DAxis(gridPlaneAxis, Initialiser.Interface, out gwaRec);

            if (gwaRec != null)
            {
                this.SubGWACommand.Add(gwaRec);
            }
            double elevation = gridPlaneElevation;

            var polylineDescription = "";

            switch (pieces[counter++])
            {
            case "PLANE":
                // TODO: Do not handle for now
                return;

            case "POLYREF":
                var    polylineRef = pieces[counter++];
                string newRec      = null;
                Helper.GetPolylineDesc(Convert.ToInt32(polylineRef), out polylineDescription, out newRec);
                this.SubGWACommand.Add(newRec);
                break;

            case "POLYGON":
                polylineDescription = pieces[counter++];
                break;
            }
            var polyVals = Helper.ParsePolylineDesc(polylineDescription);

            for (var i = 2; i < polyVals.Length; i += 3)
            {
                polyVals[i] = elevation;
            }

            obj.Value = Helper.MapPointsLocal2Global(polyVals, axis).ToList();

            obj.LoadCaseRef = Helper.GetApplicationId(typeof(GSALoadCase).GetGSAKeyword(), Convert.ToInt32(pieces[counter++]));

            var            loadAxisId   = 0;
            var            loadAxisData = pieces[counter++];
            StructuralAxis loadAxis;

            if (loadAxisData == "LOCAL")
            {
                loadAxis = axis;
            }
            else
            {
                loadAxisId = loadAxisData == "GLOBAL" ? 0 : Convert.ToInt32(loadAxisData);
                loadAxis   = Helper.Parse0DAxis(loadAxisId, Initialiser.Interface, out gwaRec);
                if (gwaRec != null)
                {
                    this.SubGWACommand.Add(gwaRec);
                }
            }
            var projected    = pieces[counter++] == "YES";
            var direction    = pieces[counter++];
            var firstValue   = Convert.ToDouble(pieces[counter++]);
            var secondValue  = Convert.ToDouble(pieces[counter++]);
            var averageValue = (firstValue + secondValue) / 2;

            obj.Loading = new StructuralVectorSix(new double[6]);
            switch (direction.ToUpper())
            {
            case "X":
                obj.Loading.Value[0] = averageValue;
                break;

            case "Y":
                obj.Loading.Value[1] = averageValue;
                break;

            case "Z":
                obj.Loading.Value[2] = averageValue;
                break;
            }
            obj.Loading.TransformOntoAxis(loadAxis);

            if (projected)
            {
                var scale = (obj.Loading.Value[0] * axis.Normal.Value[0] +
                             obj.Loading.Value[1] * axis.Normal.Value[1] +
                             obj.Loading.Value[2] * axis.Normal.Value[2]) /
                            (axis.Normal.Value[0] * axis.Normal.Value[0] +
                             axis.Normal.Value[1] * axis.Normal.Value[1] +
                             axis.Normal.Value[2] * axis.Normal.Value[2]);

                obj.Loading = new StructuralVectorSix(axis.Normal.Value[0], axis.Normal.Value[1], axis.Normal.Value[2], 0, 0, 0);
                obj.Loading.Scale(scale);
            }

            obj.LoadingEnd = new StructuralVectorSix(new double[6]);
            switch (direction.ToUpper())
            {
            case "X":
                obj.LoadingEnd.Value[0] = averageValue;
                break;

            case "Y":
                obj.LoadingEnd.Value[1] = averageValue;
                break;

            case "Z":
                obj.LoadingEnd.Value[2] = averageValue;
                break;
            }
            obj.LoadingEnd.TransformOntoAxis(loadAxis);

            if (projected)
            {
                var scale = (obj.LoadingEnd.Value[0] * axis.Normal.Value[0] +
                             obj.LoadingEnd.Value[1] * axis.Normal.Value[1] +
                             obj.LoadingEnd.Value[2] * axis.Normal.Value[2]) /
                            (axis.Normal.Value[0] * axis.Normal.Value[0] +
                             axis.Normal.Value[1] * axis.Normal.Value[1] +
                             axis.Normal.Value[2] * axis.Normal.Value[2]);

                obj.LoadingEnd = new StructuralVectorSix(axis.Normal.Value[0], axis.Normal.Value[1], axis.Normal.Value[2], 0, 0, 0);
                obj.LoadingEnd.Scale(scale);
            }

            this.Value = obj;
        }
 //TODO
 public static Element ToNative(this Structural1DLoadLine myLoad)
 {
     return(null);
 }