<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Zoom Extents on new Database in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070825#M76981</link>
    <description>I have created a new database:&lt;BR /&gt;
     Database newDb = new Database(true, true)&lt;BR /&gt;
Inserted a block into modelspace&lt;BR /&gt;
and now I want to zoom extent before saving.&lt;BR /&gt;
&lt;BR /&gt;
Can this be done working on a new database in memory?&lt;BR /&gt;
all the examples I have seen on this board use Interop on a open document.&lt;BR /&gt;
&lt;BR /&gt;
Does anyone have a point in the right direction</description>
    <pubDate>Tue, 18 Sep 2007 01:23:42 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2007-09-18T01:23:42Z</dc:date>
    <item>
      <title>Zoom Extents on new Database</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070825#M76981</link>
      <description>I have created a new database:&lt;BR /&gt;
     Database newDb = new Database(true, true)&lt;BR /&gt;
Inserted a block into modelspace&lt;BR /&gt;
and now I want to zoom extent before saving.&lt;BR /&gt;
&lt;BR /&gt;
Can this be done working on a new database in memory?&lt;BR /&gt;
all the examples I have seen on this board use Interop on a open document.&lt;BR /&gt;
&lt;BR /&gt;
Does anyone have a point in the right direction</description>
      <pubDate>Tue, 18 Sep 2007 01:23:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070825#M76981</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-09-18T01:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Extents on new Database</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070826#M76982</link>
      <description>Others have posted lots of good working methodologies ... search on zoomextents&lt;BR /&gt;
&lt;BR /&gt;
Maybe these lines will give you a start ....&lt;BR /&gt;
&lt;BR /&gt;
AcadApplication app = (AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;&lt;BR /&gt;
db.TileMode = false;//*PAPER_SPACE&lt;BR /&gt;
db.TileMode = true;//*MODEL_SPACE&lt;BR /&gt;
app.ZoomExtents();&lt;BR /&gt;
------------------&lt;BR /&gt;
LayoutManager layoutMgr = LayoutManager.Current;&lt;BR /&gt;
                layoutMgr.CurrentLayout = "Model";&lt;BR /&gt;
                AcadApplication pApp = (Autodesk.AutoCAD.Interop.AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;&lt;BR /&gt;
                pApp.ZoomExtents();&lt;BR /&gt;
                db.UpdateExt(true);</description>
      <pubDate>Tue, 18 Sep 2007 16:49:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070826#M76982</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-09-18T16:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Extents on new Database</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070827#M76983</link>
      <description>Thanks for the reply&lt;BR /&gt;
&lt;BR /&gt;
It seems Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication&lt;BR /&gt;
ONLY apply to the document currently displayed in autocad.&lt;BR /&gt;
&lt;BR /&gt;
Maybe I am missing a step but let me try to explain the problem again.&lt;BR /&gt;
I have a drawing (drawing1) open.&lt;BR /&gt;
I run my command that creates a NEW database in memory.&lt;BR /&gt;
I insert a block in the NEW database (in memory) and I want to&lt;BR /&gt;
Zoom extents and then save the database (drawing2).&lt;BR /&gt;
When I use the examples in this forum including yours it zoom extents alright but in drawing1, not the new database.&lt;BR /&gt;
&lt;BR /&gt;
I am still learning so I could be overlooking something&lt;BR /&gt;
Any help is appreciated.</description>
      <pubDate>Wed, 19 Sep 2007 09:21:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070827#M76983</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-09-19T09:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Extents on new Database</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070828#M76984</link>
      <description>I'm not sure, but I don't think that ActiveX commands can be applied to the in-memory drawing.&lt;BR /&gt;
Again, I might be mistaken.</description>
      <pubDate>Wed, 19 Sep 2007 11:48:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070828#M76984</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-09-19T11:48:13Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Extents on new Database</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070829#M76985</link>
      <description>I don't think you can zoom a *database*.&lt;BR /&gt;
A *document* is required.</description>
      <pubDate>Wed, 19 Sep 2007 20:28:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070829#M76985</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-09-19T20:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Extents on new Database</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070830#M76986</link>
      <description>Correct, it has to be the current dwg in the editor to do display changes.</description>
      <pubDate>Wed, 19 Sep 2007 22:13:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070830#M76986</guid>
      <dc:creator>Ed__Jobe</dc:creator>
      <dc:date>2007-09-19T22:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Extents on new Database</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070831#M76987</link>
      <description>Who told you that?&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2008&lt;BR /&gt;
Supporting AutoCAD 2000 through 2008&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;ED_JOBE&gt; wrote in message news:5726557@discussion.autodesk.com...&lt;BR /&gt;
Correct, it has to be the current dwg in the editor to do display changes.&lt;/ED_JOBE&gt;</description>
      <pubDate>Wed, 19 Sep 2007 22:54:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070831#M76987</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-09-19T22:54:04Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Extents on new Database</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070832#M76988</link>
      <description>Thanks everyone&lt;BR /&gt;
&lt;BR /&gt;
Maybe I can come at it from a different angle then.&lt;BR /&gt;
When I complete the operations to the database save it and then open it as a drawing in AutoCAD, the view has been set for me, not where I would like (the extents of the block inserted)&lt;BR /&gt;
&lt;BR /&gt;
How does one control where the initial view is located when creating a database?&lt;BR /&gt;
&lt;BR /&gt;
Or is that view default and the need to specify has been overlooked?</description>
      <pubDate>Thu, 20 Sep 2007 07:56:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070832#M76988</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-09-20T07:56:23Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Extents on new Database</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070833#M76989</link>
      <description>Tony,&lt;BR /&gt;
Is there a way to "zoom" a database?&lt;BR /&gt;
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.&lt;BR /&gt;
Am I missing something? I know that there are plenty of undocumented or otherwise hidden pieces to the programming puzzle.&lt;BR /&gt;
&lt;BR /&gt;
By the way, your CommandLine.cs worked fine for zooming but again that would only work on the currently active drawing.</description>
      <pubDate>Thu, 20 Sep 2007 18:43:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070833#M76989</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-09-20T18:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Extents on new Database</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070834#M76990</link>
      <description>SO maybe zoom extents is not what I want.&lt;BR /&gt;
&lt;BR /&gt;
Is there a way to specify the initial view on a new database.&lt;BR /&gt;
The view is set by autocad when you create a new db can we change that default view I guess is the question?&lt;BR /&gt;
&lt;BR /&gt;
Anyone know how?&lt;BR /&gt;
Is it possible</description>
      <pubDate>Thu, 20 Sep 2007 20:10:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070834#M76990</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-09-20T20:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Extents on new Database</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070835#M76991</link>
      <description>Yes Mark, there is a way to "zoom a database"&lt;BR /&gt;
&lt;BR /&gt;
In the case of a database that's not open in the &lt;BR /&gt;
AutoCAD editor, "zoom" means to set the view&lt;BR /&gt;
parameters to whatever is required to achieve&lt;BR /&gt;
the desired view (e.g., the center, magnification, &lt;BR /&gt;
direction, etc.).&lt;BR /&gt;
&lt;BR /&gt;
If you think about it, AutoCAD must read something&lt;BR /&gt;
in the drawing file to determine the initial view&lt;BR /&gt;
when it opens the file (which for a drawing that was &lt;BR /&gt;
previously open in the editor, is the view that was &lt;BR /&gt;
current when the file was saved).&lt;BR /&gt;
&lt;BR /&gt;
See this thread for the gory details:&lt;BR /&gt;
&lt;BR /&gt;
http://discussion.autodesk.com/adskcsp/thread.jspa?messageID=5541432&lt;BR /&gt;
&lt;BR /&gt;
For zooming to the extents, you could call the&lt;BR /&gt;
UpdateExts() method of the Database, and then&lt;BR /&gt;
read the Extmin and Extmax properties to get&lt;BR /&gt;
the box that has to fit in the view. If the view&lt;BR /&gt;
is not plan, then it becomes a bit more difficult.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2008&lt;BR /&gt;
Supporting AutoCAD 2000 through 2008&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;MARK johnston=""&gt; wrote in message news:5727528@discussion.autodesk.com...&lt;BR /&gt;
&lt;BR /&gt;
Tony,&lt;BR /&gt;
Is there a way to "zoom" a database?&lt;BR /&gt;
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.&lt;BR /&gt;
Am I missing something? I know that there are plenty of undocumented or otherwise hidden pieces to the programming puzzle.&lt;BR /&gt;
&lt;BR /&gt;
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&lt;/MARK&gt;</description>
      <pubDate>Fri, 21 Sep 2007 06:41:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070835#M76991</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-09-21T06:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Extents on new Database</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070836#M76992</link>
      <description>See my reply to Mark.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2008&lt;BR /&gt;
Supporting AutoCAD 2000 through 2008&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;TECHNO destructo=""&gt; wrote in message news:5727623@discussion.autodesk.com...&lt;BR /&gt;
SO maybe zoom extents is not what I want.&lt;BR /&gt;
&lt;BR /&gt;
Is there a way to specify the initial view on a new database.&lt;BR /&gt;
The view is set by autocad when you create a new db can we change that default view I guess is the question?&lt;BR /&gt;
&lt;BR /&gt;
Anyone know how?&lt;BR /&gt;
Is it possible&lt;/TECHNO&gt;</description>
      <pubDate>Fri, 21 Sep 2007 06:41:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070836#M76992</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-09-21T06:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Extents on new Database</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070837#M76993</link>
      <description>Anyboby has a sample of code in paperspace ? This function works well in modelspace :&lt;BR /&gt;
    &lt;BR /&gt;
Sub ZoomExtents(ByVal myDB As Autodesk.AutoCAD.DatabaseServices.Database)&lt;BR /&gt;
    Dim tm As Autodesk.AutoCAD.DatabaseServices.Transaction = myDB.TransactionManager.StartTransaction&lt;BR /&gt;
    Try&lt;BR /&gt;
        If myDB.TileMode = True Then 'Model&lt;BR /&gt;
            Dim vpt As ViewportTable = tm.GetObject(myDB.ViewportTableId, OpenMode.ForRead)&lt;BR /&gt;
            Dim vptr As ViewportTableRecord = tm.GetObject(vpt.Item("*Active"), OpenMode.ForWrite)&lt;BR /&gt;
            Dim pt3Max As Point3d = myDB.Extmax&lt;BR /&gt;
            Dim pt3Min As Point3d = myDB.Extmin&lt;BR /&gt;
            Dim pt2Max As Autodesk.AutoCAD.Geometry.Point2d = New Autodesk.AutoCAD.Geometry.Point2d(pt3Max.X, pt3Max.Y)&lt;BR /&gt;
            Dim pt2Min As Autodesk.AutoCAD.Geometry.Point2d = New Autodesk.AutoCAD.Geometry.Point2d(pt3Min.X, pt3Min.Y)&lt;BR /&gt;
            vptr.CenterPoint = (pt2Min + (pt2Max - pt2Min) / 2.0)&lt;BR /&gt;
            vptr.Height = (pt2Max.Y - pt2Min.Y)&lt;BR /&gt;
            vptr.Width = (pt2Max.X - pt2Min.X)&lt;BR /&gt;
            myDB.UpdateExt(True)&lt;BR /&gt;
        Else 'Papier&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
        End If&lt;BR /&gt;
    Catch ex As Exception&lt;BR /&gt;
        MsgBox("Erreur de zoom, " &amp;amp; ex.Message)&lt;BR /&gt;
    Finally&lt;BR /&gt;
        tm.Commit()&lt;BR /&gt;
        tm.Dispose()&lt;BR /&gt;
    End Try&lt;BR /&gt;
End Sub</description>
      <pubDate>Mon, 13 Jul 2009 18:22:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/2070837#M76993</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-07-13T18:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Extents on new Database</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/3287129#M76994</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;aks&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2012 16:40:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/3287129#M76994</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-01-10T16:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Extents on new Database</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/7510872#M76995</link>
      <description>&lt;P&gt;I am trying change the code mentioned &lt;A href="http://www.acadnetwork.com/index.php?topic=232.0" target="_blank"&gt;in here&lt;/A&gt; to use for paperspace.&lt;/P&gt;
&lt;P&gt;I tried by changing the code as highlighted below and its not working.&lt;/P&gt;
&lt;P&gt;Can anyone help me to show what I am doing wrong or any another way to zoom extent the paperspace of a document which is not active in the editor ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE style="margin: 0; padding: 0;"&gt;&lt;CODE class="bbc_code"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// Sets a zoom extents of the Database model space&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name="db"&amp;gt;The Database instance this method applies to.&amp;lt;/param&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public static void ZoomExtents(this Database db)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; db.TileMode = &lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;false&lt;/STRONG&gt;&lt;/FONT&gt;;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Point2d scrSize = (Point2d)AcAp.GetSystemVariable("screensize");&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; double ratio = scrSize.X / scrSize.Y;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; using (Transaction tr = db.TransactionManager.StartTransaction())&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; using (Line line = new Line(&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;db.Pextmin, db.Pextmax&lt;/STRONG&gt;&lt;/FONT&gt;))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ViewportTable vpt =&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (ViewportTable)tr.GetObject(db.ViewportTableId, OpenMode.ForRead);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ViewportTableRecord vptr =&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (ViewportTableRecord)tr.GetObject(vpt["*Active"], OpenMode.ForWrite);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Extents3d ext = line.GeometricExtents;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ext.TransformBy(vptr.WorldToEye());&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Point2d pmin = new Point2d(ext.MinPoint.X, ext.MinPoint.Y);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Point2d pmax = new Point2d(ext.MaxPoint.X, ext.MaxPoint.Y);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; double height = pmax.Y - pmin.Y;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; double width = pmax.X - pmin.X;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (width / height &amp;lt; ratio)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; vptr.Height = height;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; vptr.Width = height * ratio;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; vptr.Width = width;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; vptr.Height = width / ratio;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; vptr.CenterPoint = pmin + (pmax - pmin) / 2.0;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tr.Commit();&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2017 10:56:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/7510872#M76995</guid>
      <dc:creator>Ajilal.Vijayan</dc:creator>
      <dc:date>2017-11-02T10:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Extents on new Database</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/7512383#M76996</link>
      <description>&lt;P&gt;I don't know if you can easily adapt the code you posted or not, because it is dependent on a number of things that require the document and the paperspace layout to be active (for example, the SCREENSIZE system variable, the *Active ViewportTableRecord, etc.). If the document is not active in the editor&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not suggesting it isn't possible to do, but given how the code is written, a great deal of it is dependent on the active document and layout.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ajilal.Vijayan wrote:&lt;/P&gt;&lt;P&gt;I am trying change the code mentioned &lt;A href="http://www.acadnetwork.com/index.php?topic=232.0" target="_blank"&gt;in here&lt;/A&gt; to use for paperspace.&lt;/P&gt;&lt;P&gt;I tried by changing the code as highlighted below and its not working.&lt;/P&gt;&lt;P&gt;Can anyone help me to show what I am doing wrong or any another way to zoom extent the paperspace of a document which is not active in the editor ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// Sets a zoom extents of the Database model space&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name="db"&amp;gt;The Database instance this method applies to.&amp;lt;/param&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public static void ZoomExtents(this Database db)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; db.TileMode = &lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;false&lt;/STRONG&gt;&lt;/FONT&gt;;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Point2d scrSize = (Point2d)AcAp.GetSystemVariable("screensize");&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; double ratio = scrSize.X / scrSize.Y;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; using (Transaction tr = db.TransactionManager.StartTransaction())&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; using (Line line = new Line(&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;db.Pextmin, db.Pextmax&lt;/STRONG&gt;&lt;/FONT&gt;))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ViewportTable vpt =&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (ViewportTable)tr.GetObject(db.ViewportTableId, OpenMode.ForRead);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ViewportTableRecord vptr =&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (ViewportTableRecord)tr.GetObject(vpt["*Active"], OpenMode.ForWrite);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Extents3d ext = line.GeometricExtents;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ext.TransformBy(vptr.WorldToEye());&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Point2d pmin = new Point2d(ext.MinPoint.X, ext.MinPoint.Y);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Point2d pmax = new Point2d(ext.MaxPoint.X, ext.MaxPoint.Y);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; double height = pmax.Y - pmin.Y;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; double width = pmax.X - pmin.X;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (width / height &amp;lt; ratio)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; vptr.Height = height;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; vptr.Width = height * ratio;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; vptr.Width = width;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; vptr.Height = width / ratio;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; vptr.CenterPoint = pmin + (pmax - pmin) / 2.0;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tr.Commit();&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2017 16:58:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/7512383#M76996</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2017-11-02T16:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Extents on new Database</title>
      <link>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/7548640#M76997</link>
      <description>&lt;P&gt;Thanks for the reply &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4476837"&gt;@ActivistInvestor&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;In modelsapce this code works with the the documents which are not active in the editor.&lt;/P&gt;
&lt;P&gt;So I tried with _db.GetViewports(true) and used the first objectid of that collection to get the Viewport.&lt;/P&gt;
&lt;P&gt;This seems to be working.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ObjectIdCollection vpcol = _db.GetViewports(true);
                    if (vpcol.Count &amp;gt; 0)//Check whether the layout is initialiazed
                    {
                        Viewport vport = (Viewport)_tr.GetObject(vpcol[0], OpenMode.ForWrite);
                        vport.ViewHeight = (width / height) &amp;lt; ratio ? height : width / ratio;
                        vport.ViewCenter = pmin + (pmax - pmin) / 2.0;
                    }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 07:44:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/zoom-extents-on-new-database/m-p/7548640#M76997</guid>
      <dc:creator>Ajilal.Vijayan</dc:creator>
      <dc:date>2017-11-16T07:44:19Z</dc:date>
    </item>
  </channel>
</rss>

