Exemplo n.º 1
0
        public static void PaintTileInBtr(ObjectId idBtr, RTree <ColorArea> rtreeColorAreas, Matrix3d transToModel)
        {
            var btr = idBtr.GetObject(OpenMode.ForRead) as BlockTableRecord;

            foreach (ObjectId idEnt in btr)
            {
                if (idEnt.IsValidEx() && idEnt.ObjectClass.Name == "AcDbBlockReference")
                {
                    var    blRef  = idEnt.GetObject(OpenMode.ForRead, false, true) as BlockReference;
                    string blName = blRef.GetEffectiveName();
                    if (blName.StartsWith(Settings.Default.BlockTileName, StringComparison.OrdinalIgnoreCase))
                    {
                        Tile tile = new Tile(blRef, blName);
                        //Определение покраски плитки
                        Paint paint = ColorArea.GetPaint(tile.CenterTile.TransformBy(transToModel), rtreeColorAreas);
                        if (paint != null)
                        {
                            blRef.UpgradeOpen();
                            blRef.Layer = paint.Layer;
                            FillTileArticle(blRef, paint.Article); // Так же поворачивает атрибут
                            //tile.SetPaint(paint);
                        }
                    }
                    else if (!MarkSb.IsBlockNamePanel(blName))
                    {
                        // Покраска во вложенных блоках, кроме АРК панелей
                        PaintTileInBtr(blRef.BlockTableRecord, rtreeColorAreas, blRef.BlockTransform * transToModel);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private static void IterateColorAreasInBtr(ObjectId idBtr, Album album,
                                                   List <ColorArea> colorAreas, Matrix3d matrix, string xrefName, AcadLib.Layers.LayerVisibleState lvs)
        {
            var btr = idBtr.GetObject(OpenMode.ForRead) as BlockTableRecord;

            foreach (ObjectId idEnt in btr)
            {
                if (idEnt.IsValidEx() && idEnt.ObjectClass.Name == "AcDbBlockReference")
                {
                    var blRefColorArea = idEnt.GetObject(OpenMode.ForRead, false, true) as BlockReference;
                    if (!lvs.IsVisible(blRefColorArea))
                    {
                        continue;
                    }
                    var blName = getBlNameWithoutXrefPrefix(blRefColorArea.GetEffectiveName(), xrefName);
                    if (blName.StartsWith(Settings.Default.BlockColorAreaName, StringComparison.InvariantCultureIgnoreCase))
                    {
                        var colorArea = new ColorArea(blRefColorArea, album, matrix);
                        colorAreas.Add(colorArea);
                    }
                    else
                    {
                        // Если это не блок Панели, то ищем вложенные в блоки зоны покраски
                        if (!MarkSb.IsBlockNamePanel(blName))
                        {
                            var btrInner = blRefColorArea.BlockTableRecord.GetObject(OpenMode.ForRead) as BlockTableRecord;
                            // Обработка вложенных зон покраски в блок
                            if (btrInner.IsFromExternalReference)
                            {
                                IterateColorAreasInBtr(btrInner.Id, album, colorAreas,
                                                       blRefColorArea.BlockTransform.PostMultiplyBy(matrix), btrInner.Name, lvs);
                            }
                            else
                            {
                                IterateColorAreasInBtr(btrInner.Id, album, colorAreas,
                                                       blRefColorArea.BlockTransform.PostMultiplyBy(matrix), xrefName, lvs);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        public static List <ObjectId> GetPanelsBlRefInModel(Database db)
        {
            List <ObjectId> ids = new List <ObjectId>();

            using (var t = db.TransactionManager.StartTransaction())
            {
                var ms = t.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForRead) as BlockTableRecord;
                foreach (ObjectId idEnt in ms)
                {
                    if (idEnt.IsValidEx() && idEnt.ObjectClass.Name == "AcDbBlockReference")
                    {
                        var blRef = t.GetObject(idEnt, OpenMode.ForRead, false, true) as BlockReference;
                        if (MarkSb.IsBlockNamePanel(blRef.Name))
                        {
                            ids.Add(idEnt);
                        }
                    }
                }
                t.Commit();
            }
            return(ids);
        }