Esempio n. 1
0
        private static void copyItem(ColorArea item, ObjectIdCollection idColToCopy, ObjectId idBtrOwner, Transaction t)
        {
            using (IdMapping map = new IdMapping())
            {
                Db.DeepCloneObjects(idColToCopy, idBtrOwner, map, false);
                ObjectId idBlRefCopy = map[idColToCopy[0]].Value;

                if (idBlRefCopy.IsValid && !idBlRefCopy.IsNull)
                {
                    using (var blRefCopy = t.GetObject(idBlRefCopy, OpenMode.ForWrite, false, true) as BlockReference)
                    {
                        blRefCopy.Position = new Point3d(Base.X + item.Pos.X, Base.Y + item.Pos.Y, 0);
                        blRefCopy.Layer    = item.EntInfo.Layer;
                    }
                }
            }
        }
Esempio n. 2
0
        public static void Copy()
        {
            Init();
            ToCopy = new List <ColorArea>();
            // Выбор блоков зон покраски.

            var idsSelect = GetSelection();

            Base   = Ed.GetPointWCS("Базовая точка");
            Layers = new Dictionary <string, LayerInfo>();
            // Фильтр зон покраски
            using (var t = Db.TransactionManager.StartTransaction())
            {
                foreach (var idBlRef in idsSelect)
                {
                    var blRef = idBlRef.GetObject(OpenMode.ForRead, false, true) as BlockReference;
                    if (blRef == null)
                    {
                        continue;
                    }
                    var blName = blRef.GetEffectiveName();
                    if (blName.Equals(Settings.Default.BlockColorAreaName, StringComparison.OrdinalIgnoreCase))
                    {
                        ColorArea ca = new ColorArea(blRef);
                        ToCopy.Add(ca);
                        // добавление слоя в словарь
                        if (!Layers.ContainsKey(blRef.Layer))
                        {
                            LayerInfo li = new LayerInfo(blRef.LayerId);
                            Layers.Add(li.Name, li);
                        }
                    }
                }
                t.Commit();
            }
            Ed.WriteMessage($"\nСкопировано {ToCopy.Count} блоков зон покраски.");
        }
        private static void copyItem(ColorArea item, ObjectIdCollection idColToCopy, ObjectId idBtrOwner, Transaction t)
        {
            using (IdMapping map = new IdMapping())
            {
                Db.DeepCloneObjects(idColToCopy, idBtrOwner, map, false);
                ObjectId idBlRefCopy = map[idColToCopy[0]].Value;

                if (idBlRefCopy.IsValid && !idBlRefCopy.IsNull)
                {
                    using (var blRefCopy = t.GetObject(idBlRefCopy, OpenMode.ForWrite, false, true) as BlockReference)
                    {
                        blRefCopy.Position = new Point3d(Base.X + item.Pos.X, Base.Y + item.Pos.Y, 0);
                        blRefCopy.Layer = item.EntInfo.Layer;
                    }
                }
            }
        }
        public static void Copy()
        {
            Init();
            ToCopy = new List<ColorArea>();
            // Выбор блоков зон покраски.

            var idsSelect = GetSelection();
            Base = Ed.GetPointWCS("Базовая точка");
            Layers = new Dictionary<string, LayerInfo>();
            // Фильтр зон покраски
            using (var t = Db.TransactionManager.StartTransaction())
            {
                foreach (var idBlRef in idsSelect)
                {
                    var blRef = idBlRef.GetObject(OpenMode.ForRead, false, true) as BlockReference;
                    if (blRef == null) continue;
                    var blName = blRef.GetEffectiveName();
                    if (blName.Equals(Settings.Default.BlockColorAreaName, StringComparison.OrdinalIgnoreCase))
                    {
                        ColorArea ca = new ColorArea(blRef);
                        ToCopy.Add(ca);
                        // добавление слоя в словарь
                        if(!Layers.ContainsKey(blRef.Layer))
                        {
                            LayerInfo li = new LayerInfo(blRef.LayerId);
                            Layers.Add(li.Name, li);
                        }
                    }
                }
                t.Commit();
            }
            Ed.WriteMessage($"\nСкопировано {ToCopy.Count} блоков зон покраски.");
        }