Ejemplo n.º 1
0
        public static SpeckleObject ToSpeckle(this GSASpringProperty dummyObject)
        {
            var newLines = ToSpeckleBase <GSASpringProperty>();

            //Get all relevant GSA entities in this entire model
            var springProperties = new List <GSASpringProperty>();

            foreach (var p in newLines.Values)
            {
                try
                {
                    var springProperty = new GSASpringProperty()
                    {
                        GWACommand = p
                    };
                    springProperty.ParseGWACommand();
                    springProperties.Add(springProperty);
                }
                catch { }
            }

            Initialiser.GSASenderObjects[typeof(GSASpringProperty)].AddRange(springProperties);

            return((springProperties.Count() > 0) ? new SpeckleObject() : new SpeckleNull());
        }
        public static SpeckleObject ToSpeckle(this GSASpringProperty dummyObject)
        {
            var newLines = ToSpeckleBase <GSASpringProperty>();

            var springPropLock = new object();
            //Get all relevant GSA entities in this entire model
            var springProperties = new List <GSASpringProperty>();

            Parallel.ForEach(newLines.Values, p =>
            {
                try
                {
                    var springProperty = new GSASpringProperty()
                    {
                        GWACommand = p
                    };
                    springProperty.ParseGWACommand();
                    lock (springPropLock)
                    {
                        springProperties.Add(springProperty);
                    }
                }
                catch { }
            });

            Initialiser.GSASenderObjects.AddRange(springProperties);

            return((springProperties.Count() > 0) ? new SpeckleObject() : new SpeckleNull());
        }
Ejemplo n.º 3
0
    public static SpeckleObject ToSpeckle(this GSASpringProperty dummyObject)
    {
      var newLines = ToSpeckleBase<GSASpringProperty>();
      var typeName = dummyObject.GetType().Name;

      var springPropLock = new object();
      //Get all relevant GSA entities in this entire model
      var springProperties = new SortedDictionary<int, GSASpringProperty>();

#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];
        try
        {
          var springProperty = new GSASpringProperty() { GWACommand = newLines[k] };
          springProperty.ParseGWACommand();
          lock (springPropLock)
          {
            springProperties.Add(k, springProperty);
          }
        }
        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(springProperties.Values.ToList());

      return (springProperties.Keys.Count > 0) ? new SpeckleObject() : new SpeckleNull();
    }
 public static SpeckleObject ToSpeckle(this GSASpringProperty dummyObject) => (new GsaPropSpr()).ToSpeckle();
Ejemplo n.º 5
0
        public bool ForceSend; // This is to filter only "important" nodes

        public void ParseGWACommand()
        {
            // NODE.3 | num | name | colour | x | y | z | restraint | axis |
            // mesh_size | springProperty | massProperty | damperProperty

            if (this.GWACommand == null)
            {
                return;
            }

            var obj = new StructuralNode();

            var pieces = this.GWACommand.ListSplit(Initialiser.AppResources.Proxy.GwaDelimiter);

            var counter = 1;                                                // Skip identifier

            this.GSAId        = Convert.ToInt32(pieces[counter++]);         // num
            obj.ApplicationId = Helper.GetApplicationId(this.GetGSAKeyword(), this.GSAId);
            obj.Name          = pieces[counter++].Trim(new char[] { '"' }); // name
            counter++;                                                      // colour
            obj.Value = new List <double>
            {
                Convert.ToDouble(pieces[counter++]), // x
                Convert.ToDouble(pieces[counter++]), // y
                Convert.ToDouble(pieces[counter++])  // z
            };

            if (counter >= pieces.Length)
            {
                this.Value = obj;
                return;
            }

            if (counter < pieces.Length)
            {
                obj.Restraint = Helper.RestraintFromCode(pieces[counter++]); // restraint
            }

            if (counter < pieces.Length)
            {
                // axis
                var axis = pieces[counter++];
                if (string.IsNullOrEmpty(axis) || axis == "GLOBAL")
                {
                    obj.Axis = Helper.Global;
                }
                else
                {
                    string gwaRec = null;
                    obj.Axis = Helper.Parse0DAxis(Convert.ToInt32(axis), out gwaRec, obj.Value.ToArray());
                    if (gwaRec != null)
                    {
                        this.SubGWACommand.Add(gwaRec);
                    }
                }
            }

            if (counter < pieces.Length)
            {
                obj.GSALocalMeshSize = pieces[counter++].ToDouble(); // mesh_size
            }

            if (counter < pieces.Length)
            {
                // springProperty
                var spKeyword      = typeof(GSASpringProperty).GetGSAKeyword().Split('.').First();
                var springPropsGwa = Initialiser.AppResources.Cache.GetGwa(spKeyword, Convert.ToInt32(pieces[counter++])); // not sure how this could ever return multiple?
                if (springPropsGwa.Count > 0)
                {
                    var springPropGWA = springPropsGwa[0];
                    var springProp    = new GSASpringProperty();
                    springProp.GWACommand = springPropGWA;
                    springProp.ParseGWACommand();
                    obj.Stiffness = springProp.Value.Stiffness;
                }
            }

            if (counter < pieces.Length)
            {
                // massProperty
                // Speckle node currently only supports single mass, rather than the more complicated PROP_MASS in GSA
                var massPropsGwa = Initialiser.AppResources.Cache.GetGwa("PROP_MASS", Convert.ToInt32(pieces[counter++]));
                if (massPropsGwa.Count > 0)
                {
                    var massPropGwa    = massPropsGwa[0];
                    var massPropPieces = massPropGwa.ListSplit(Initialiser.AppResources.Proxy.GwaDelimiter);
                    obj.Mass = Convert.ToDouble(massPropPieces[5]);
                }
            }

            // damperProperty - not yet supported

            this.Value = obj;
        }