public static SpeckleObject ToSpeckle(this GSA1DElement dummyObject) { var settings = Initialiser.AppResources.Settings; var anyElement1dResults = settings.ResultTypes != null && settings.ResultTypes.Any(rt => rt.ToString().ToLower().Contains("1d")); if (settings.TargetLayer == GSATargetLayer.Analysis && settings.StreamSendConfig == StreamContentConfig.TabularResultsOnly && !anyElement1dResults) { return new SpeckleNull(); } var newLines = ToSpeckleBase<GSA1DElement>(); var typeName = dummyObject.GetType().Name; var elementsLock = new object(); var elements = new SortedDictionary<int, GSA1DElement>(); var nodes = Initialiser.GsaKit.GSASenderObjects.Get<GSANode>(); var keyword = dummyObject.GetGSAKeyword(); #if DEBUG foreach (var k in newLines.Keys) #else Parallel.ForEach(newLines.Keys, k => #endif { var pPieces = newLines[k].ListSplit(Initialiser.AppResources.Proxy.GwaDelimiter); if (pPieces[4] == "BEAM" && pPieces[4].ParseElementNumNodes() == 2) { var gsaId = pPieces[1]; try { var element = new GSA1DElement() { GWACommand = newLines[k] }; element.ParseGWACommand(nodes); lock (elementsLock) { elements.Add(k, element); } } catch (Exception ex) { Initialiser.AppResources.Messenger.Message(MessageIntent.TechnicalLog, MessageLevel.Error, ex, "Keyword=" + keyword, "Index=" + k); } } } #if !DEBUG ); #endif if (elements.Values.Count() > 0) { Initialiser.GsaKit.GSASenderObjects.AddRange(elements.Values.ToList()); } return (elements.Keys.Count > 0) ? new SpeckleObject() : new SpeckleNull(); }
public static SpeckleObject ToSpeckle(this GSA1DElement dummyObject) { var newLines = ToSpeckleBase<GSA1DElement>(); var typeName = dummyObject.GetType().Name; var elementsLock = new object(); var elements = new SortedDictionary<int, GSA1DElement>(); var nodes = Initialiser.GsaKit.GSASenderObjects.Get<GSANode>(); #if DEBUG foreach (var k in newLines.Keys) #else Parallel.ForEach(newLines.Keys, k => #endif { var pPieces = newLines[k].ListSplit(Initialiser.AppResources.Proxy.GwaDelimiter); if (pPieces[4] == "BEAM" && pPieces[4].ParseElementNumNodes() == 2) { var gsaId = pPieces[1]; try { var element = new GSA1DElement() { GWACommand = newLines[k] }; element.ParseGWACommand(nodes); lock (elementsLock) { elements.Add(k, element); } } catch (Exception ex) { Initialiser.AppResources.Messenger.CacheMessage(MessageIntent.Display, MessageLevel.Error, typeName, gsaId); Initialiser.AppResources.Messenger.CacheMessage(MessageIntent.TechnicalLog, MessageLevel.Error, ex, typeName, gsaId); } } } #if !DEBUG ); #endif Initialiser.GsaKit.GSASenderObjects.AddRange(elements.Values.ToList()); return (elements.Keys.Count > 0) ? new SpeckleObject() : new SpeckleNull(); }