Пример #1
0
        private void ZoomToFlaechenGrenzen()
        {
            log.DebugFormat(CultureInfo.CurrentCulture, "Zoom auf Flächengrenzen");
            if (_FlaechenGrenzen.Count == 0)
            {
                return;
            }

            double MinX, MinY, MaxX, MaxY;

            _AcAp.Document           doc = _AcAp.Application.DocumentManager.MdiActiveDocument;
            _AcDb.Database           db  = doc.Database;
            _AcEd.Editor             ed  = doc.Editor;
            _AcDb.TransactionManager tm  = db.TransactionManager;
            _AcDb.Transaction        myT = tm.StartTransaction();
            try
            {
                _AcDb.Extents3d ext = GetExtents(tm, _FlaechenGrenzen[0]);
                MinX = ext.MinPoint.X;
                MinY = ext.MinPoint.Y;
                MaxX = ext.MaxPoint.X;
                MaxY = ext.MaxPoint.Y;

                for (int i = 1; i < _FlaechenGrenzen.Count; i++)
                {
                    _AcDb.ObjectId oid = _FlaechenGrenzen[i];
                    ext = GetExtents(tm, oid);
                    if (ext.MinPoint.X < MinX)
                    {
                        MinX = ext.MinPoint.X;
                    }
                    if (ext.MinPoint.Y < MinY)
                    {
                        MinY = ext.MinPoint.Y;
                    }
                    if (ext.MaxPoint.X > MaxX)
                    {
                        MaxX = ext.MaxPoint.X;
                    }
                    if (ext.MaxPoint.Y > MaxY)
                    {
                        MaxY = ext.MaxPoint.Y;
                    }
                }


                //Globs.Zoom( new Point3d(MinX, MinY, 0.0), new Point3d(MaxX, MaxY, 0.0),new Point3d(), 1.0);
                //Globs.ZoomWin3(ed, new Point3d(MinX, MinY, 0.0), new Point3d(MaxX, MaxY, 0.0));
                //Globs.ZoomWin2(ed, new Point3d(MinX, MinY, 0.0), new Point3d(MaxX, MaxY, 0.0));

                myT.Commit();
            }
            finally
            {
                myT.Dispose();
            }

            // Rauszoomen, sonst werden Blöcken nicht gefunden, die außerhalb der Flächengrenzen liegen.
            MinX -= ABSTANDTEXT;
            MinY -= ABSTANDTEXT;
            MaxX += ABSTANDTEXT;
            MaxY += ABSTANDTEXT;

            Globs.Zoom(new _AcGe.Point3d(MinX, MinY, 0.0), new _AcGe.Point3d(MaxX, MaxY, 0.0), new _AcGe.Point3d(), 1.0);
        }