public static SpeckleObject ToSpeckle(this GSA1DElement dummyObject)
        {
            var newLines = ToSpeckleBase <GSA1DElement>();

            var elements = new List <GSA1DElement>();
            var nodes    = Initialiser.GSASenderObjects[typeof(GSANode)].Cast <GSANode>().ToList();

            foreach (var p in newLines.Values)
            {
                var pPieces = p.ListSplit("\t");

                if (pPieces[4] == "BEAM" && pPieces[4].ParseElementNumNodes() == 2)
                {
                    try
                    {
                        var element = new GSA1DElement()
                        {
                            GWACommand = p
                        };
                        element.ParseGWACommand(nodes);
                        elements.Add(element);
                    }
                    catch { }
                }
            }

            Initialiser.GSASenderObjects[typeof(GSA1DElement)].AddRange(elements);

            return((elements.Count() > 0) ? new SpeckleObject() : new SpeckleNull());
        }
Beispiel #2
0
        public static SpeckleObject ToSpeckle(this GSA1DElement dummyObject)
        {
            var newLines = ToSpeckleBase <GSA1DElement>();

            var elementsLock = new object();
            var elements     = new List <GSA1DElement>();
            var nodes        = Initialiser.GSASenderObjects.Get <GSANode>();

            Parallel.ForEach(newLines.Values, p =>
            {
                var pPieces = p.ListSplit("\t");

                if (pPieces[4] == "BEAM" && pPieces[4].ParseElementNumNodes() == 2)
                {
                    try
                    {
                        var element = new GSA1DElement()
                        {
                            GWACommand = p
                        };
                        element.ParseGWACommand(nodes);
                        lock (elementsLock)
                        {
                            elements.Add(element);
                        }
                    }
                    catch { }
                }
            });

            Initialiser.GSASenderObjects.AddRange(elements);

            return((elements.Count() > 0) ? new SpeckleObject() : new SpeckleNull());
        }
    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();
    }
Beispiel #4
0
    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();
    }