public static SpeckleObject ToSpeckle(this GSA1DMember dummyObject) { var nodes = Initialiser.GSASenderObjects[typeof(GSANode)].Cast <GSANode>().ToList(); var members = new List <GSA1DMember>(); var newLines = ToSpeckleBase <GSA1DMember>(); foreach (var p in newLines.Values) { var pPieces = p.ListSplit("\t"); if (pPieces[4].Is1DMember()) { try { var member = new GSA1DMember() { GWACommand = p }; member.ParseGWACommand(nodes); members.Add(member); } catch { } } } Initialiser.GSASenderObjects[typeof(GSA1DMember)].AddRange(members); return((members.Count() > 0) ? new SpeckleObject() : new SpeckleNull()); }
public static SpeckleObject ToSpeckle(this GSA1DMember dummyObject) { var nodes = Initialiser.GSASenderObjects.Get <GSANode>(); var membersLock = new object(); var members = new List <GSA1DMember>(); var newLines = ToSpeckleBase <GSA1DMember>(); Parallel.ForEach(newLines.Values, p => { var pPieces = p.ListSplit("\t"); if (pPieces[4].Is1DMember()) { try { var member = new GSA1DMember() { GWACommand = p }; member.ParseGWACommand(nodes); lock (membersLock) { members.Add(member); } } catch { } } }); Initialiser.GSASenderObjects.AddRange(members); return((members.Count() > 0) ? new SpeckleObject() : new SpeckleNull()); }
public string SetGWACommand() { if (this.Value == null) return ""; var obj = this.Value as Structural1DElementPolyline; if (obj.Value == null || obj.Value.Count() == 0) return ""; var elements = obj.Explode(); var gwaCommands = new List<string>(); if (Initialiser.AppResources.Settings.TargetLayer == GSATargetLayer.Design) { var coords = obj.basePolyline.Value.Take(3).Union(obj.basePolyline.Value.Skip(obj.basePolyline.Value.Count - 3).Take(3)).ToList(); var member1d = new Structural1DElement() { //This might have more than 6 items (i.e. 2 XYZ points) which is incompatible with SpeckleLine but there is no enforcement of 6 values for SpeckleLine at this point //- the codebase around ToNative() for design-layer polylines needs to be refactored to avoid this "overloading" of the Value list ApplicationId = obj.ApplicationId, Name = obj.Name, Value = obj.basePolyline.Value, ElementType = obj.ElementType, PropertyRef = obj.PropertyRef, EndRelease = obj.EndRelease, Offset = obj.Offset, Properties = obj.Properties, GSAMeshSize = obj.GSAMeshSize, GSADummy = obj.GSADummy }; var gsa1dMember = new GSA1DMember() { Value = member1d }; gwaCommands.Add(gsa1dMember.SetGWACommand()); } else if (elements.Count() == 1) { gwaCommands.Add(new GSA1DElement() { Value = elements.First() }.SetGWACommand()); } else { var group = Initialiser.AppResources.Cache.ResolveIndex(typeof(GSA1DElementPolyline).GetGSAKeyword(), obj.ApplicationId); #if DEBUG foreach (var element in elements) #else Parallel.ForEach(elements, element => #endif { gwaCommands.Add(new GSA1DElement() { Value = element }.SetGWACommand(group)); } #if !DEBUG ); #endif } return string.Join("\n", gwaCommands); }
public static SpeckleObject ToSpeckle(this GSA1DMember dummyObject) { var nodes = Initialiser.GsaKit.GSASenderObjects.Get<GSANode>(); var membersLock = new object(); var members = new SortedDictionary<int, GSA1DMember>(); var newLines = ToSpeckleBase<GSA1DMember>(); var typeName = dummyObject.GetType().Name; 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); var gsaId = pPieces[1]; if (pPieces[4].Is1DMember()) { try { var member = new GSA1DMember() { GWACommand = newLines[k] }; member.ParseGWACommand(nodes); lock (membersLock) { members.Add(k, member); } } catch (Exception ex) { Initialiser.AppResources.Messenger.Message(MessageIntent.TechnicalLog, MessageLevel.Error, ex, "Keyword=" + keyword, "Index=" + k); } } } #if !DEBUG ); #endif if (members.Values.Count() > 0) { Initialiser.GsaKit.GSASenderObjects.AddRange(members.Values.ToList()); } return (members.Keys.Count() > 0) ? new SpeckleObject() : new SpeckleNull(); }