コード例 #1
0
        //The ToNative() method is in the new schema conversion folder hierarchy

        public static SpeckleObject ToSpeckle(this GSAAssembly dummyObject)
        {
            var newLines       = ToSpeckleBase <GSAAssembly>();
            var typeName       = dummyObject.GetType().Name;
            var assembliesLock = new object();

            //Get all relevant GSA entities in this entire model
            var assemblies = new SortedDictionary <int, GSAAssembly>();
            var nodes      = Initialiser.GsaKit.GSASenderObjects.Get <GSANode>();
            var e1Ds       = new List <GSA1DElement>();
            var e2Ds       = new List <GSA2DElement>();
            var m1Ds       = new List <GSA1DMember>();
            var m2Ds       = new List <GSA2DMember>();

            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 assembly = new GSAAssembly()
                    {
                        GWACommand = newLines[k], GSAId = k
                    };
                    //Pass in ALL the nodes and members - the Parse_ method will search through them
                    assembly.ParseGWACommand(nodes, e1Ds, e2Ds, m1Ds, m2Ds);

                    //This ties into the note further above:
                    //Unlike all other classes, the layer relevant to sending is only determined by looking at a GWA parameter rather than a class attribute.
                    //Once this condition has been met, assign to null so it won't form part of the sender objects list
                    if (assembly.Value != null)
                    {
                        lock (assembliesLock)
                        {
                            assemblies.Add(k, assembly);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Initialiser.AppResources.Messenger.CacheMessage(MessageIntent.Display, MessageLevel.Error, typeName, k.ToString());
                    Initialiser.AppResources.Messenger.CacheMessage(MessageIntent.TechnicalLog, MessageLevel.Error, ex, typeName, k.ToString());
                }
            });

            Initialiser.GsaKit.GSASenderObjects.AddRange(assemblies.Values.ToList());

            return((assemblies.Keys.Count > 0) ? new SpeckleObject() : new SpeckleNull());
        }
コード例 #2
0
        public static SpeckleObject ToSpeckle(this GSAAssembly dummyObject)
        {
            var newLines = ToSpeckleBase <GSAAssembly>();

            var assembliesLock = new object();

            //Get all relevant GSA entities in this entire model
            var assemblies = new List <GSAAssembly>();
            var nodes      = Initialiser.GSASenderObjects.Get <GSANode>();
            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 assembly = new GSAAssembly()
                    {
                        GWACommand = p
                    };
                    //Pass in ALL the nodes and members - the Parse_ method will search through them
                    assembly.ParseGWACommand(nodes, e1Ds, e2Ds, m1Ds, m2Ds);

                    //This ties into the note further above:
                    //Unlike all other classes, the layer relevant to sending is only determined by looking at a GWA parameter rather than a class attribute.
                    //Once this condition has been met, assign to null so it won't form part of the sender objects list
                    if (assembly.Value != null)
                    {
                        lock (assembliesLock)
                        {
                            assemblies.Add(assembly);
                        }
                    }
                }
                catch { }
            });

            Initialiser.GSASenderObjects.AddRange(assemblies);

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