Esempio n. 1
0
        // Определение покраски панели (список цветов по порядку списка плитов в блоке СБ)
        public static List <Paint> GetPanelMarkAR(MarkSb markSb, BlockReference blRefPanel, RTree <ColorArea> rtreeColorAreas)
        {
            List <Paint> paintsAR = new List <Paint>();

            int  i = 0;
            bool hasTileWithoutPaint = false;

            foreach (Tile tileMarSb in markSb.Tiles)
            {
                Paint paintSb = markSb.Paints[i++];
                Paint paintAR;
                if (paintSb == null)
                {
                    // Опрделение покраски по зонам
                    Point3d centerTileInBlRef = GetCenterTileInBlockRef(blRefPanel.Position, tileMarSb.CenterTile);
                    paintAR = ColorArea.GetPaint(centerTileInBlRef, rtreeColorAreas);
                    if (paintAR == null)
                    {
                        if (!hasTileWithoutPaint)
                        {
                            //Ошибка. Не удалось определить покраску плитки.???
                            Inspector.AddError($"{markSb.MarkSbClean} - не все плитки покрашены", blRefPanel, icon: System.Drawing.SystemIcons.Error);
                            hasTileWithoutPaint = true;
                        }
                    }
                }
                else
                {
                    paintAR = paintSb;
                }
                paintsAR.Add(paintAR);
            }
            return(paintsAR);
        }
Esempio n. 2
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);
                    }
                }
            }
        }
Esempio n. 3
0
 public MarkAr(List <Paint> paintAR, MarkSb markSb, BlockReference blRefMarkAr)
 {
     Album      = markSb.Album;
     _markSB    = markSb;
     _abbrIndex = string.IsNullOrEmpty(_markSB.Abbr) ? "" : "_" + _markSB.Abbr;
     _paints    = paintAR;
     DefMarkArTempNames(markSb, blRefMarkAr.Name);
     _panels = new List <Panel>();
 }
Esempio n. 4
0
        /// <summary>
        /// Определение границ блока по блокам плитки внутри
        /// </summary>
        /// <param name="markSB"></param>
        /// <returns></returns>
        public Extents3d GetExtentsTiles(MarkSb markSB)
        {
            // границы в определении блока
            var extTilesBtr = markSB.ExtentsTiles;

            // трансформация границ из BTR в BlRef
            if (_idBlRefAr.IsNull || _idBlRefAr.IsErased || !_idBlRefAr.IsValid)
            {
                return(_extents);
            }
            using (var blRef = _idBlRefAr.Open(OpenMode.ForRead, false, true) as BlockReference)
            {
                var matrix = blRef.BlockTransform;
                extTilesBtr.TransformBy(matrix);
                _extents = extTilesBtr;
            }
            return(extTilesBtr);
        }
Esempio n. 5
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);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
 private void DefMarkArTempNames(MarkSb markSB, string blName)
 {
     _markArTemp = markSB.MarksAR.Count.ToString(); // "АР-" + markSB.MarksAR.Count.ToString();
 }