Example #1
0
        public static SpeckleObject ToSpeckle(this GSABridgeAlignment dummyObject)
        {
            var newLines       = ToSpeckleBase <GSABridgeAlignment>();
            var typeName       = dummyObject.GetType().Name;
            var alignmentsLock = new object();

            //Get all relevant GSA entities in this entire model
            var alignments = new SortedDictionary <int, GSABridgeAlignment>();

            Parallel.ForEach(newLines.Keys, k =>
            {
                var alignment = new GSABridgeAlignment()
                {
                    GWACommand = newLines[k]
                };
                //Pass in ALL the nodes and members - the Parse_ method will search through them
                try
                {
                    alignment.ParseGWACommand();
                    lock (alignmentsLock)
                    {
                        alignments.Add(k, alignment);
                    }
                }
                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(alignments.Values.ToList());

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

            var alignmentsLock = new object();

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

            Parallel.ForEach(newLines.Values, p =>
            {
                var alignment = new GSABridgeAlignment()
                {
                    GWACommand = p
                };
                //Pass in ALL the nodes and members - the Parse_ method will search through them
                alignment.ParseGWACommand();
                lock (alignmentsLock)
                {
                    alignments.Add(alignment);
                }
            });

            Initialiser.GSASenderObjects.AddRange(alignments);

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