Ejemplo n.º 1
0
        public static SpeckleObject ToSpeckle(this GSAConstructionStage dummyObject)
        {
            var newLines      = ToSpeckleBase <GSAConstructionStage>();
            var typeName      = dummyObject.GetType().Name;
            var stageDefsLock = new object();
            var stageDefs     = new SortedDictionary <int, GSAConstructionStage>();
            var e1Ds          = new List <GSA1DElement>();
            var e2Ds          = new List <GSA2DElement>();
            var m1Ds          = new List <GSA1DMember>();
            var m2Ds          = new List <GSA2DMember>();
            var keyword       = dummyObject.GetGSAKeyword();

            if (Initialiser.AppResources.Settings.TargetLayer == GSATargetLayer.Analysis)
            {
                e1Ds = Initialiser.GsaKit.GSASenderObjects.Get <GSA1DElement>();
                e2Ds = Initialiser.GsaKit.GSASenderObjects.Get <GSA2DElement>();
            }
            else if (Initialiser.AppResources.Settings.TargetLayer == GSATargetLayer.Design)
            {
                m1Ds = Initialiser.GsaKit.GSASenderObjects.Get <GSA1DMember>();
                m2Ds = Initialiser.GsaKit.GSASenderObjects.Get <GSA2DMember>();
            }

            Parallel.ForEach(newLines.Keys, k =>
            {
                try
                {
                    var stageDef = new GSAConstructionStage()
                    {
                        GWACommand = newLines[k]
                    };
                    stageDef.ParseGWACommand(e1Ds, e2Ds, m1Ds, m2Ds);
                    lock (stageDefsLock)
                    {
                        stageDefs.Add(k, stageDef);
                    }
                }
                catch (Exception ex)
                {
                    Initialiser.AppResources.Messenger.Message(MessageIntent.TechnicalLog, MessageLevel.Error, ex,
                                                               "Keyword=" + keyword, "Index=" + k);
                }
            });

            if (stageDefs.Values.Count() > 0)
            {
                Initialiser.GsaKit.GSASenderObjects.AddRange(stageDefs.Values.ToList());
            }

            return((stageDefs.Keys.Count > 0) ? new SpeckleObject() : new SpeckleNull());
        }
Ejemplo n.º 2
0
        public static SpeckleObject ToSpeckle(this GSAConstructionStage dummyObject)
        {
            var newLines = ToSpeckleBase <GSAConstructionStage>();

            var stageDefsLock = new object();
            var stageDefs     = new List <GSAConstructionStage>();
            var e1Ds          = new List <GSA1DElement>();
            var e2Ds          = new List <GSA2DElement>();
            var m1Ds          = new List <GSA1DMember>();
            var m2Ds          = new List <GSA2DMember>();

            if (Initialiser.Settings.TargetLayer == GSATargetLayer.Analysis)
            {
                e1Ds = Initialiser.GSASenderObjects.Get <GSA1DElement>();
                e2Ds = Initialiser.GSASenderObjects.Get <GSA2DElement>();
            }
            else if (Initialiser.Settings.TargetLayer == GSATargetLayer.Design)
            {
                m1Ds = Initialiser.GSASenderObjects.Get <GSA1DMember>();
                m2Ds = Initialiser.GSASenderObjects.Get <GSA2DMember>();
            }

            Parallel.ForEach(newLines.Values, p =>
            {
                try
                {
                    var stageDef = new GSAConstructionStage()
                    {
                        GWACommand = p
                    };
                    stageDef.ParseGWACommand(e1Ds, e2Ds, m1Ds, m2Ds);
                    lock (stageDefsLock)
                    {
                        stageDefs.Add(stageDef);
                    }
                }
                catch { }
            });

            Initialiser.GSASenderObjects.AddRange(stageDefs);

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

            var stageDefs = new List <GSAConstructionStage>();
            var e1Ds      = new List <GSA1DElement>();
            var e2Ds      = new List <GSA2DElement>();
            var m1Ds      = new List <GSA1DMember>();
            var m2Ds      = new List <GSA2DMember>();

            if (Initialiser.Settings.TargetLayer == GSATargetLayer.Analysis)
            {
                e1Ds = Initialiser.GSASenderObjects[typeof(GSA1DElement)].Cast <GSA1DElement>().ToList();
                e2Ds = Initialiser.GSASenderObjects[typeof(GSA2DElement)].Cast <GSA2DElement>().ToList();
            }
            else if (Initialiser.Settings.TargetLayer == GSATargetLayer.Design)
            {
                m1Ds = Initialiser.GSASenderObjects[typeof(GSA1DMember)].Cast <GSA1DMember>().ToList();
                m2Ds = Initialiser.GSASenderObjects[typeof(GSA2DMember)].Cast <GSA2DMember>().ToList();
            }

            foreach (var p in newLines.Values)
            {
                try
                {
                    var stageDef = new GSAConstructionStage()
                    {
                        GWACommand = p
                    };
                    stageDef.ParseGWACommand(e1Ds, e2Ds, m1Ds, m2Ds);
                    stageDefs.Add(stageDef);
                }
                catch { }
            }

            Initialiser.GSASenderObjects[typeof(GSAConstructionStage)].AddRange(stageDefs);

            return((stageDefs.Count() > 0) ? new SpeckleObject() : new SpeckleNull());
        }