public static SpeckleObject ToSpeckle(this GSA0DLoad dummyObject) { var newLines = ToSpeckleBase <GSA0DLoad>(); var loads = new List <GSA0DLoad>(); var nodes = Initialiser.GSASenderObjects[typeof(GSANode)].Cast <GSANode>().ToList(); foreach (var p in newLines.Values) { var loadSubList = new List <GSA0DLoad>(); // Placeholder load object to get list of nodes and load values // Need to transform to axis so one load definition may be transformed to many var initLoad = new GSA0DLoad() { GWACommand = p }; initLoad.ParseGWACommand(nodes); // Raise node flag to make sure it gets sent foreach (var n in nodes.Where(n => initLoad.Value.NodeRefs.Contains(n.Value.ApplicationId))) { n.ForceSend = true; } // Create load for each node applied foreach (string nRef in initLoad.Value.NodeRefs) { var load = new GSA0DLoad { 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 node = nodes.Where(n => (n.Value.ApplicationId == nRef)).First(); string gwaRecord = null; StructuralAxis loadAxis = HelperClass.Parse0DAxis(initLoad.Axis, Initialiser.Interface, out gwaRecord, node.Value.Value.ToArray()); load.Value.Loading = initLoad.Value.Loading; load.Value.Loading.TransformOntoAxis(loadAxis); // If the loading already exists, add node 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.NodeRefs.Add(nRef); if (gwaRecord != null) { match.SubGWACommand.Add(gwaRecord); } } else { load.Value.NodeRefs = new List <string>() { nRef }; if (gwaRecord != null) { load.SubGWACommand.Add(gwaRecord); } loadSubList.Add(load); } } loads.AddRange(loadSubList); } Initialiser.GSASenderObjects[typeof(GSA0DLoad)].AddRange(loads); return((loads.Count() > 0) ? new SpeckleObject() : new SpeckleNull()); }
//The ToNative() method is in the new schema conversion folder hierarchy //Reminder: the SpeckleSA application won't find this on its own because the type (Gsa0dLoad) isn't marked as a IGSASpeckleContainer public static SpeckleObject ToSpeckle(this GSA0DLoad dummyObject) => (new GsaLoadNode()).ToSpeckle();