In the case of a database that's not open in the
AutoCAD editor, "zoom" means to set the view
parameters to whatever is required to achieve
the desired view (e.g., the center, magnification,
If you think about it, AutoCAD must read something
in the drawing file to determine the initial view
when it opens the file (which for a drawing that was
previously open in the editor, is the view that was
current when the file was saved).
For zooming to the extents, you could call the
UpdateExts() method of the Database, and then
read the Extmin and Extmax properties to get
the box that has to fit in the view. If the view
is not plan, then it becomes a bit more difficult.
AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
wrote in message news:firstname.lastname@example.org...
Is there a way to "zoom" a database?
I made my comment based on my attempts at doing just that. I browsed the object model but saw no zoom functionality associated with the databaseservices. I only found zoom used with the application object and that only effected the active document.
Am I missing something? I know that there are plenty of undocumented or otherwise hidden pieces to the programming puzzle.
By the way, your CommandLine.cs worked fine for zooming but again that would only work on the currently active drawing.
Message was edited by: Discussion Admin
Anyboby has a sample of code in paperspace ? This function works well in modelspace :
Sub ZoomExtents(ByVal myDB As Autodesk.AutoCAD.DatabaseServices.Database)
Dim tm As Autodesk.AutoCAD.DatabaseServices.Transaction = myDB.TransactionManager.StartTransaction
If myDB.TileMode = True Then 'Model
Dim vpt As ViewportTable = tm.GetObject(myDB.ViewportTableId, OpenMode.ForRead)
Dim vptr As ViewportTableRecord = tm.GetObject(vpt.Item("*Active"), OpenMode.ForWrite)
Dim pt3Max As Point3d = myDB.Extmax
Dim pt3Min As Point3d = myDB.Extmin
Dim pt2Max As Autodesk.AutoCAD.Geometry.Point2d = New Autodesk.AutoCAD.Geometry.Point2d(pt3Max.X, pt3Max.Y)
Dim pt2Min As Autodesk.AutoCAD.Geometry.Point2d = New Autodesk.AutoCAD.Geometry.Point2d(pt3Min.X, pt3Min.Y)
vptr.CenterPoint = (pt2Min + (pt2Max - pt2Min) / 2.0)
vptr.Height = (pt2Max.Y - pt2Min.Y)
vptr.Width = (pt2Max.X - pt2Min.X)
Catch ex As Exception
MsgBox("Erreur de zoom, " & ex.Message)