• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    *Tony Tanzillo

    Re: Zoom Extents on new Database

    09-20-2007 11:41 PM in reply to: Techno Destructo
    Yes Mark, there is a way to "zoom a database"

    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,
    direction, etc.).

    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).

    See this thread for the gory details:

    http://discussion.autodesk.com/adskcsp/thread.jspa?messageID=5541432

    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.

    --
    http://www.caddzone.com

    AcadXTabs: MDI Document Tabs for AutoCAD 2008
    Supporting AutoCAD 2000 through 2008
    http://www.acadxtabs.com

    wrote in message news:5727528@discussion.autodesk.com...

    Tony,
    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
    Please use plain text.
    *Tony Tanzillo

    Re: Zoom Extents on new Database

    09-20-2007 11:41 PM in reply to: Techno Destructo
    See my reply to Mark.

    --
    http://www.caddzone.com

    AcadXTabs: MDI Document Tabs for AutoCAD 2008
    Supporting AutoCAD 2000 through 2008
    http://www.acadxtabs.com

    wrote in message news:5727623@discussion.autodesk.com...
    SO maybe zoom extents is not what I want.

    Is there a way to specify the initial view on a new database.
    The view is set by autocad when you create a new db can we change that default view I guess is the question?

    Anyone know how?
    Is it possible
    Please use plain text.
    New Member
    Posts: 1
    Registered: ‎07-13-2009

    Re: Zoom Extents on new Database

    07-13-2009 11:22 AM in reply to: Techno Destructo
    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
    Try
    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)
    myDB.UpdateExt(True)
    Else 'Papier



    End If
    Catch ex As Exception
    MsgBox("Erreur de zoom, " & ex.Message)
    Finally
    tm.Commit()
    tm.Dispose()
    End Try
    End Sub
    Please use plain text.
    Valued Contributor
    Posts: 85
    Registered: ‎03-23-2009

    Re: Zoom Extents on new Database

    01-10-2012 08:39 AM in reply to: cblais

    Thanks cblais for the code. I needed to use it, but in order for this to work a myDB.UpdateExt(True) must be executed before retrieving the Extmax and Extmin values just as Tony Z stated on 9/20/07.

     

    aks

    Please use plain text.