Ejemplo n.º 1
0
        public void Replace()
        {
            ObjectId idBtrWin;

            if (dictIdBtrAkrWindow == null)
            {
                dictIdBtrAkrWindow = getBtrAkrWin(UtilsReplaceWindows.Db);
            }
            dictIdBtrAkrWindow.TryGetValue(TranslatorW.BlNameNew, out idBtrWin);

            if (idBtrWin.IsNull)
            {
                throw new Exception($"Ошибка, не найден блок окна {TranslatorW.BlNameNew}.");
            }

            // Создание вхождения нового блока окнак
            var blRefNew = new BlockReference(Position, idBtrWin);

            blRefNew.SetDatabaseDefaults();
            blRefNew.Layer = Settings.Default.LayerWindows;
            // добавление его в определение блок
            var btrOwner = IdBtrOwner.GetObject(OpenMode.ForWrite) as BlockTableRecord;

            btrOwner.AppendEntity(blRefNew);
            UtilsReplaceWindows.Transaction.AddNewlyCreatedDBObject(blRefNew, true);
            // Удаление старого блока.
            var blRefOldWin = IdBlRef.GetObject(OpenMode.ForWrite, false, true) as BlockReference;

            blRefOldWin.Erase();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Вставка чистого блока сваи и установка текущих параметров
        /// </summary>
        public void ResetBlock()
        {
            var t     = IdBtrOwner.Database.TransactionManager.TopTransaction;
            var owner = IdBtrOwner.GetObject(OpenMode.ForWrite) as BlockTableRecord;
            var blRef = BlockInsert.InsertBlockRef(BlName, Position, owner, t);

            blRef.LayerId = LayerId;

            var oldBlRef = IdBlRef.GetObject(OpenMode.ForWrite) as BlockReference;

            oldBlRef.Erase();

            var oldProps = Properties.Select(s => (Property)s.Clone());

            Update(blRef);
            foreach (var item in Properties.Where(p => p.IsShow))
            {
                var oldProp = oldProps.First(p => p.Name == item.Name);
                FillProp(item, oldProp.Value);
            }
        }