<?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 View Table in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/view-table/m-p/2994754#M61127</link>
    <description>&lt;DIV&gt;Good Morning,&lt;BR /&gt;&lt;BR /&gt;I have a simple program that when run checks if a given view is in the View Table for a drawing, if it is it will load it by default. The program works fine when it checks for the view. However the problem I am running into is that it does not change to the view afterwards. Any thoughts? Code below.&lt;BR /&gt;&lt;BR /&gt;&amp;lt;code&amp;gt;&lt;BR /&gt;&lt;BR /&gt;[CommandMethod("def")]&lt;BR /&gt;static public void DefViewLoad() // This method can have any name&lt;BR /&gt;{&lt;BR /&gt;//Set current application session&lt;BR /&gt;AcadApplication app;&lt;BR /&gt;app = (Autodesk.AutoCAD.Interop.AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;// Get current DWG Database&lt;BR /&gt;Document acDoc = Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt;Database acDB = acDoc.Database;&lt;BR /&gt;&lt;BR /&gt;//Set Editor to save typing&lt;BR /&gt;Editor ed = acDoc.Editor;&lt;BR /&gt;&lt;BR /&gt;//Start Transaction to play with DWG.&lt;BR /&gt;&lt;BR /&gt;using (Transaction acTran = acDB.TransactionManager.StartTransaction())&lt;BR /&gt;{&lt;BR /&gt;//Open current drawing layer table listing and read.&lt;BR /&gt;ViewTable acVT;&lt;BR /&gt;acVT = acTran.GetObject(acDB.ViewTableId, OpenMode.ForRead) as ViewTable;&lt;BR /&gt;ViewTableRecord acVTRec = new ViewTableRecord();&lt;BR /&gt;&lt;BR /&gt;if (acVT.Has("test")==true)&lt;BR /&gt;{&lt;BR /&gt;ed.WriteMessage("test works");&lt;BR /&gt;acVTRec.Name = "test";&lt;BR /&gt;&lt;BR /&gt;ed.SetCurrentView(acVTRec);&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;acTran.Commit();&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;ed.Regen();&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;lt;/code&amp;gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 19 Apr 2011 12:11:20 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2011-04-19T12:11:20Z</dc:date>
    <item>
      <title>View Table</title>
      <link>https://forums.autodesk.com/t5/net-forum/view-table/m-p/2994754#M61127</link>
      <description>&lt;DIV&gt;Good Morning,&lt;BR /&gt;&lt;BR /&gt;I have a simple program that when run checks if a given view is in the View Table for a drawing, if it is it will load it by default. The program works fine when it checks for the view. However the problem I am running into is that it does not change to the view afterwards. Any thoughts? Code below.&lt;BR /&gt;&lt;BR /&gt;&amp;lt;code&amp;gt;&lt;BR /&gt;&lt;BR /&gt;[CommandMethod("def")]&lt;BR /&gt;static public void DefViewLoad() // This method can have any name&lt;BR /&gt;{&lt;BR /&gt;//Set current application session&lt;BR /&gt;AcadApplication app;&lt;BR /&gt;app = (Autodesk.AutoCAD.Interop.AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;// Get current DWG Database&lt;BR /&gt;Document acDoc = Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt;Database acDB = acDoc.Database;&lt;BR /&gt;&lt;BR /&gt;//Set Editor to save typing&lt;BR /&gt;Editor ed = acDoc.Editor;&lt;BR /&gt;&lt;BR /&gt;//Start Transaction to play with DWG.&lt;BR /&gt;&lt;BR /&gt;using (Transaction acTran = acDB.TransactionManager.StartTransaction())&lt;BR /&gt;{&lt;BR /&gt;//Open current drawing layer table listing and read.&lt;BR /&gt;ViewTable acVT;&lt;BR /&gt;acVT = acTran.GetObject(acDB.ViewTableId, OpenMode.ForRead) as ViewTable;&lt;BR /&gt;ViewTableRecord acVTRec = new ViewTableRecord();&lt;BR /&gt;&lt;BR /&gt;if (acVT.Has("test")==true)&lt;BR /&gt;{&lt;BR /&gt;ed.WriteMessage("test works");&lt;BR /&gt;acVTRec.Name = "test";&lt;BR /&gt;&lt;BR /&gt;ed.SetCurrentView(acVTRec);&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;acTran.Commit();&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;ed.Regen();&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;lt;/code&amp;gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 19 Apr 2011 12:11:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/view-table/m-p/2994754#M61127</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-04-19T12:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: View Table</title>
      <link>https://forums.autodesk.com/t5/net-forum/view-table/m-p/2995638#M61128</link>
      <description>&lt;P&gt;You have simply created a new ViewTableRecord (with defaults which would match the currently active settings), then named it "test" and set the view.&amp;nbsp; You need to open the existing record to pass to SetCurrentView.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use VB, so I'm not going to try too hard to get this syntax right, but you should get the idea.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if (acVT.Has("test")==true)&amp;nbsp; // This can return true for erased objects&lt;BR /&gt;{&lt;BR /&gt;ed.WriteMessage("test works");&lt;BR /&gt;acVTRec = acTran.GetObject(acVT("test"), OpenMode.ForRead, False); //Open the record&lt;BR /&gt;&amp;nbsp; // I would check here to make sure acVtRec.IsErased = False&lt;/P&gt;&lt;P&gt;&amp;nbsp; if (acVTRec.IsErased==false)&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp; ed.SetCurrentView(acVTRec);&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2011 20:05:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/view-table/m-p/2995638#M61128</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2011-04-19T20:05:43Z</dc:date>
    </item>
  </channel>
</rss>

