예제 #1
0
        public static void ShowEnt(this ObjectId id, Extents3d ext, Document docOrig)
        {
            var curDoc = Application.DocumentManager.MdiActiveDocument;

            if (docOrig != curDoc)
            {
                Application.ShowAlertDialog($"Должен быть активен документ {docOrig.Name}");
            }
            else
            {
                if (ext.Diagonal() > 1)
                {
                    docOrig.Editor.Zoom(ext);
                    id.FlickObjectHighlight(2, 100, 100);
                    docOrig.Editor.SetImpliedSelection(new[] { id });

                    // docOrig.Editor.AddEntToImpliedSelection(id);
                }
                else
                {
                    Application.ShowAlertDialog("Границы элемента не определены");
                }
            }
        }
예제 #2
0
        private void сreateHatch(Extents3d extText, BlockTableRecord btr)
        {
            if (extText.Diagonal() < 100)
            {
                return;
            }
            // Отступ контура штриховки от границ текста
            Extents3d ext = new Extents3d(new Point3d(extText.MinPoint.X - 10, extText.MinPoint.Y - 10, 0),
                                          new Point3d(extText.MaxPoint.X + 10, extText.MaxPoint.Y + 10, 0));
            var h = new Hatch();
            h.SetDatabaseDefaults(btr.Database);
            if (!panelBtr.CaptionLayerId.IsNull)
                h.LayerId = panelBtr.CaptionLayerId;
            h.LineWeight = LineWeight.LineWeight015;
            h.Linetype = SymbolUtilityServices.LinetypeContinuousName;
            h.Color = Color.FromRgb(250, 250, 250);
            h.Transparency = new Transparency(80);
            h.SetHatchPattern(HatchPatternType.PreDefined, "ANGLE");
            h.PatternScale = 25.0;
            btr.AppendEntity(h);
            var t = btr.Database.TransactionManager.TopTransaction;
            t.AddNewlyCreatedDBObject(h, true);
            h.Associative = true;
            h.HatchStyle = HatchStyle.Normal;

            // Полилиния по контуру текста
            Polyline pl = new Polyline();
            pl.SetDatabaseDefaults(btr.Database);
            pl.LineWeight = LineWeight.LineWeight015;
            pl.Linetype = SymbolUtilityServices.LinetypeContinuousName;
            pl.ColorIndex = 256; // ПоСлою
            if (!panelBtr.CaptionLayerId.IsNull)
                pl.LayerId = panelBtr.CaptionLayerId;
            pl.AddVertexAt(0, ext.MinPoint.Convert2d(), 0, 0, 0);
            pl.AddVertexAt(0, new Point2d(ext.MaxPoint.X, ext.MinPoint.Y), 0, 0, 0);
            pl.AddVertexAt(0, ext.MaxPoint.Convert2d(), 0, 0, 0);
            pl.AddVertexAt(0, new Point2d(ext.MinPoint.X, ext.MaxPoint.Y), 0, 0, 0);
            pl.Closed = true;

            ObjectId idPl = btr.AppendEntity(pl);
            t.AddNewlyCreatedDBObject(pl, true);

            // добавление контура полилинии в гштриховку
            var ids = new ObjectIdCollection();
            ids.Add(idPl);
            h.AppendLoop(HatchLoopTypes.Default, ids);
            h.EvaluateHatch(true);

            // Замена текстов - чтобы они стали поверх штриховки.
            panelBtr.IdCaptionMarkSb = replaceText(panelBtr.IdCaptionMarkSb, btr);
            panelBtr.IdCaptionPaint = replaceText(panelBtr.IdCaptionPaint, btr);
        }
예제 #3
0
        private void сreateHatch(Extents3d extText, BlockTableRecord btr)
        {
            if (extText.Diagonal() < 100)
            {
                return;
            }
            // Отступ контура штриховки от границ текста
            Extents3d ext = new Extents3d(new Point3d(extText.MinPoint.X - 10, extText.MinPoint.Y - 10, 0),
                                          new Point3d(extText.MaxPoint.X + 10, extText.MaxPoint.Y + 10, 0));
            var h = new Hatch();

            h.SetDatabaseDefaults(btr.Database);
            if (!panelBtr.CaptionLayerId.IsNull)
            {
                h.LayerId = panelBtr.CaptionLayerId;
            }
            h.LineWeight   = LineWeight.LineWeight015;
            h.Linetype     = SymbolUtilityServices.LinetypeContinuousName;
            h.Color        = Color.FromRgb(250, 250, 250);
            h.Transparency = new Transparency(80);
            h.SetHatchPattern(HatchPatternType.PreDefined, "ANGLE");
            h.PatternScale = 25.0;
            btr.AppendEntity(h);
            var t = btr.Database.TransactionManager.TopTransaction;

            t.AddNewlyCreatedDBObject(h, true);
            h.Associative = true;
            h.HatchStyle  = HatchStyle.Normal;

            // Полилиния по контуру текста
            Polyline pl = new Polyline();

            pl.SetDatabaseDefaults(btr.Database);
            pl.LineWeight = LineWeight.LineWeight015;
            pl.Linetype   = SymbolUtilityServices.LinetypeContinuousName;
            pl.ColorIndex = 256; // ПоСлою
            if (!panelBtr.CaptionLayerId.IsNull)
            {
                pl.LayerId = panelBtr.CaptionLayerId;
            }
            pl.AddVertexAt(0, ext.MinPoint.Convert2d(), 0, 0, 0);
            pl.AddVertexAt(0, new Point2d(ext.MaxPoint.X, ext.MinPoint.Y), 0, 0, 0);
            pl.AddVertexAt(0, ext.MaxPoint.Convert2d(), 0, 0, 0);
            pl.AddVertexAt(0, new Point2d(ext.MinPoint.X, ext.MaxPoint.Y), 0, 0, 0);
            pl.Closed = true;

            ObjectId idPl = btr.AppendEntity(pl);

            t.AddNewlyCreatedDBObject(pl, true);

            // добавление контура полилинии в гштриховку
            var ids = new ObjectIdCollection();

            ids.Add(idPl);
            h.AppendLoop(HatchLoopTypes.Default, ids);
            h.EvaluateHatch(true);

            // Замена текстов - чтобы они стали поверх штриховки.
            panelBtr.IdCaptionMarkSb = replaceText(panelBtr.IdCaptionMarkSb, btr);
            panelBtr.IdCaptionPaint  = replaceText(panelBtr.IdCaptionPaint, btr);
        }
예제 #4
0
        public void Insert(List <string> insertBlocks)
        {
            Document        doc = Application.DocumentManager.MdiActiveDocument;
            Editor          ed  = doc.Editor;
            Database        db  = doc.Database;
            List <ObjectId> ids = new List <ObjectId>();

            Point3d   pt     = Point3d.Origin;
            Extents3d extOld = new Extents3d(pt, pt);
            double    length = 0;

            using (doc.LockDocument())
                using (var t = db.TransactionManager.StartTransaction())
                {
                    var bt = db.BlockTableId.GetObject(OpenMode.ForRead) as BlockTable;
                    var cs = db.CurrentSpaceId.GetObject(OpenMode.ForWrite) as BlockTableRecord;

                    foreach (var block in insertBlocks)
                    {
                        if (bt.Has(block))
                        {
                            var blRef = AcadLib.Blocks.BlockInsert.InsertBlockRef(block, pt, cs, t);
                            if (blRef.Bounds == null)
                            {
                            }
                            else
                            {
                                var extNew = blRef.Bounds.Value;
                                if (extOld.Diagonal() > 0)
                                {
                                    Matrix3d mat;
                                    if (Orient == BesideOrientation.Столбик)
                                    {
                                        var h = extNew.MaxPoint.Y - extNew.MinPoint.Y;
                                        var l = extNew.MaxPoint.X - extNew.MinPoint.X;
                                        if (l > length)
                                        {
                                            length = l;
                                        }
                                        var vec = extOld.MinPoint - new Point3d(extNew.MinPoint.X, extNew.MaxPoint.Y + h * 0.1, 0);
                                        mat = Matrix3d.Displacement(vec);
                                    }
                                    else
                                    {
                                        var h = extNew.MaxPoint.Y - extNew.MinPoint.Y;
                                        var l = extNew.MaxPoint.X - extNew.MinPoint.X;
                                        if (h > length)
                                        {
                                            length = h;
                                        }
                                        var vec = new Point3d(extOld.MaxPoint.X + l * 0.1, extOld.MinPoint.Y, 0) - extNew.MinPoint;
                                        mat = Matrix3d.Displacement(vec);
                                    }
                                    blRef.TransformBy(mat);
                                    extNew.TransformBy(mat);
                                }
                                extOld = extNew;
                            }
                            ids.Add(blRef.Id);
                        }
                    }

                    //using (var UI = ed.StartUserInteraction(InsertBlockBeside.win))
                    //{
                    AcadLib.Jigs.DragSel.Drag(ed, ids.ToArray(), Point3d.Origin);
                    //}
                    t.Commit();
                }
            Save();
            Logger.Log.Info($"Insert {insertBlocks?.Count}, Filter={Filter}");
        }
예제 #5
0
 public static void ShowEnt(this ObjectId id, Extents3d ext, Document docOrig)
 {
     Document curDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
     if (docOrig != curDoc)
     {
         Application.ShowAlertDialog($"Должен быть активен документ {docOrig.Name}");
     }
     else
     {
         if (ext.Diagonal() > 1)
         {
             docOrig.Editor.Zoom(ext);
             id.FlickObjectHighlight(2, 100, 100);
         }
         else
         {
             Application.ShowAlertDialog("Границы элемента не определены");
         }
     }
 }