- [Rt.CommandMethod("zoom1")] 
-         public static void zoomdb() 
-         { 
-              
-             System.Windows.Forms.OpenFileDialog openFileDialog = 
-               new System.Windows.Forms.OpenFileDialog(); 
-             openFileDialog.Title = 
-               "Выберите dwg-файл"; 
-             openFileDialog.Filter = "dwg-файлы|*.dwg"; 
-             DialogResult dr = openFileDialog.ShowDialog(); 
-             if (dr == DialogResult.Cancel) return; 
-             using (Database db = new Database(false, false)) 
-             { 
-                 db.ReadDwgFile(openFileDialog.FileName, FileOpenMode.OpenForReadAndReadShare, true, null); 
-                 Database prevDb = HostApplicationServices.WorkingDatabase; 
-                 HostApplicationServices.WorkingDatabase = db; 
-                 db.UpdateExt(true); 
-                 using (ViewportTable vTab = db.ViewportTableId.Open(OpenMode.ForRead) as ViewportTable) 
-                 { 
-                     ObjectId acVptId = vTab["*Active"]; 
-                     using (ViewportTableRecord vpTabRec = acVptId.Open(OpenMode.ForWrite) as ViewportTableRecord) 
-                     { 
-                         double scrRatio = (vpTabRec.Width / vpTabRec.Height); 
-                         Matrix3d matWCS2DCS = Matrix3d.PlaneToWorld(vpTabRec.ViewDirection); 
-                         matWCS2DCS = Matrix3d.Displacement(vpTabRec.Target - Point3d.Origin) * matWCS2DCS; 
-                         matWCS2DCS = Matrix3d.Rotation(-vpTabRec.ViewTwist, 
-                                                         vpTabRec.ViewDirection, 
-                                                         vpTabRec.Target) 
-                                                         * matWCS2DCS; 
-                         matWCS2DCS = matWCS2DCS.Inverse(); 
-                         Extents3d extents = new Extents3d(db.Extmin, db.Extmax); 
-                         extents.TransformBy(matWCS2DCS); 
-                         double width = (extents.MaxPoint.X - extents.MinPoint.X); 
-                         double height = (extents.MaxPoint.Y - extents.MinPoint.Y); 
-                         Point2d center = new Point2d((extents.MaxPoint.X + extents.MinPoint.X) * 0.5, 
-                                                      (extents.MaxPoint.Y + extents.MinPoint.Y) * 0.5); 
-                         if (width > (height * scrRatio)) 
-                             height = width / scrRatio; 
-                         vpTabRec.Height = height; 
-                         vpTabRec.Width = height * scrRatio; 
-                         vpTabRec.CenterPoint = center; 
-                     } 
-                 } 
-                 HostApplicationServices.WorkingDatabase = prevDb; 
-                 db.SaveAs(openFileDialog.FileName.Substring(0, openFileDialog.FileName.Length - 4) + 
-                   "_zoomExts.dwg", DwgVersion.Current); 
-             } 
-              
-         } 
-