public static SpeckleObject ToSpeckle(this GSA1DLoad dummyObject) { var newLines = ToSpeckleBase <GSA1DLoad>(); var loads = new List <GSA1DLoad>(); var elements = Initialiser.Settings.TargetLayer == GSATargetLayer.Analysis ? Initialiser.GSASenderObjects[typeof(GSA1DElement)].Cast <GSA1DElement>().ToList() : new List <GSA1DElement>(); var members = Initialiser.Settings.TargetLayer == GSATargetLayer.Design ? Initialiser.GSASenderObjects[typeof(GSA1DMember)].Cast <GSA1DMember>().ToList() : new List <GSA1DMember>(); foreach (var p in newLines.Values) { var loadSubList = new List <GSA1DLoad>(); // Placeholder load object to get list of elements and load values // Need to transform to axis so one load definition may be transformed to many var initLoad = new GSA1DLoad() { GWACommand = p }; initLoad.ParseGWACommand(elements, members); if (Initialiser.Settings.TargetLayer == GSATargetLayer.Analysis) { // Create load for each element applied foreach (string nRef in initLoad.Value.ElementRefs) { var load = new GSA1DLoad { GWACommand = initLoad.GWACommand, SubGWACommand = new List <string>(initLoad.SubGWACommand) }; load.Value.Name = initLoad.Value.Name; load.Value.LoadCaseRef = initLoad.Value.LoadCaseRef; // Transform load to defined axis var elem = elements.Where(e => e.Value.ApplicationId == nRef).First(); StructuralAxis loadAxis = load.Axis == 0 ? new StructuralAxis( new StructuralVectorThree(new double[] { 1, 0, 0 }), new StructuralVectorThree(new double[] { 0, 1, 0 }), new StructuralVectorThree(new double[] { 0, 0, 1 })) : HelperClass.LocalAxisEntity1D(elem.Value.Value.ToArray(), elem.Value.ZAxis); // Assumes if not global, local load.Value.Loading = initLoad.Value.Loading; load.Value.Loading.TransformOntoAxis(loadAxis); // Perform projection if (load.Projected) { var loadDirection = new Vector3D( load.Value.Loading.Value[0], load.Value.Loading.Value[1], load.Value.Loading.Value[2]); if (loadDirection.Length > 0) { var axisX = new Vector3D(elem.Value[5] - elem.Value[0], elem.Value[4] - elem.Value[1], elem.Value[3] - elem.Value[2]); var angle = Vector3D.AngleBetween(loadDirection, axisX); var factor = Math.Sin(angle); load.Value.Loading.Value[0] *= factor; load.Value.Loading.Value[1] *= factor; load.Value.Loading.Value[2] *= factor; } } // If the loading already exists, add element ref to list var match = loadSubList.Count() > 0 ? loadSubList.Where(l => (l.Value.Loading.Value as List <double>).SequenceEqual(load.Value.Loading.Value as List <double>)).First() : null; if (match != null) { match.Value.ElementRefs.Add(nRef); } else { load.Value.ElementRefs = new List <string>() { nRef }; loadSubList.Add(load); } } } else if (Initialiser.Settings.TargetLayer == GSATargetLayer.Design) { // Create load for each element applied foreach (string nRef in initLoad.Value.ElementRefs) { var load = new GSA1DLoad { GWACommand = initLoad.GWACommand, SubGWACommand = new List <string>(initLoad.SubGWACommand) }; load.Value.Name = initLoad.Value.Name; load.Value.LoadCaseRef = initLoad.Value.LoadCaseRef; // Transform load to defined axis var memb = members.Where(e => e.Value.ApplicationId == nRef).First(); StructuralAxis loadAxis = load.Axis == 0 ? new StructuralAxis( new StructuralVectorThree(new double[] { 1, 0, 0 }), new StructuralVectorThree(new double[] { 0, 1, 0 }), new StructuralVectorThree(new double[] { 0, 0, 1 })) : HelperClass.LocalAxisEntity1D(memb.Value.Value.ToArray(), memb.Value.ZAxis); // Assumes if not global, local load.Value.Loading = initLoad.Value.Loading; load.Value.Loading.TransformOntoAxis(loadAxis); // Perform projection if (load.Projected) { var loadDirection = new Vector3D( load.Value.Loading.Value[0], load.Value.Loading.Value[1], load.Value.Loading.Value[2]); if (loadDirection.Length > 0) { var axisX = new Vector3D(memb.Value[5] - memb.Value[0], memb.Value[4] - memb.Value[1], memb.Value[3] - memb.Value[2]); var angle = Vector3D.AngleBetween(loadDirection, axisX); var factor = Math.Sin(angle); load.Value.Loading.Value[0] *= factor; load.Value.Loading.Value[1] *= factor; load.Value.Loading.Value[2] *= factor; } } // If the loading already exists, add element ref to list var match = loadSubList.Count() > 0 ? loadSubList.Where(l => l.Value.Loading.Equals(load.Value.Loading)).First() : null; if (match != null) { match.Value.ElementRefs.Add(nRef); } else { load.Value.ElementRefs = new List <string>() { nRef }; loadSubList.Add(load); } } } loads.AddRange(loadSubList); } Initialiser.GSASenderObjects[typeof(GSA1DLoad)].AddRange(loads); return((loads.Count() > 0) ? new SpeckleObject() : new SpeckleNull()); }