<?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 Re: How to switch between multiple open documents? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-switch-between-multiple-open-documents/m-p/3725112#M52140</link>
    <description>&lt;P&gt;&lt;STRONG&gt;&lt;A href="http://usa.autodesk.com/adsk/servlet/index?siteID=123112&amp;amp;id=770215#vbatonet" target="_blank"&gt;AutoCAD VBA to VB.NET Migration Basics&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Dec 2012 05:47:35 GMT</pubDate>
    <dc:creator>Alexander.Rivilis</dc:creator>
    <dc:date>2012-12-06T05:47:35Z</dc:date>
    <item>
      <title>How to switch between multiple open documents?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-switch-between-multiple-open-documents/m-p/3724860#M52139</link>
      <description>&lt;P&gt;Forgive me, I am a total&amp;nbsp; beginner at this vb.net thing.&amp;nbsp; I have a vba routine that I have used for years to execute a lisp routine on an open document, then switch to the next already open document, and continue until the routine has been performed on each already open documents.&amp;nbsp; For the life of me, I cannot figure out how in vb.net to get a document collection and make each document the active document so that I can execute the lisp routine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VBA code:&lt;/P&gt;&lt;P&gt;=====================================================&lt;/P&gt;&lt;P&gt;Option Explicit&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim objAcadApp As AcadApplication&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Acad application object&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim objAcadDocs As AcadDocuments&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Acad documents collection&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim objAcadDoc As AcadDocument&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Acad document object&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim i As Integer&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;Public Sub FixAllIds()&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Get Acad objects&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set objAcadApp = GetObject(, "autoCAD.application") 'get Acad object&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set objAcadDocs = objAcadApp.Documents&amp;nbsp; 'get Acad Documents collection&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'step through open drawings&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; For i = 0 To (objAcadDocs.Count - 1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'for each drawing run c:fix-id15&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set objAcadDoc = objAcadDocs.Item(i)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; objAcadDoc.Activate&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'load the routine&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; objAcadDoc.SendCommand "lo" &amp;amp; vbCr &amp;amp; "fix-id15" &amp;amp; vbCr&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'run the routine&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; objAcadDoc.SendCommand "fix-id15" &amp;amp; vbCr&lt;BR /&gt;&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; Next i&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;End Sub&lt;/P&gt;&lt;P&gt;=====================================================&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for any advice or pointers!&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2012 23:01:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-switch-between-multiple-open-documents/m-p/3724860#M52139</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-12-05T23:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to switch between multiple open documents?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-switch-between-multiple-open-documents/m-p/3725112#M52140</link>
      <description>&lt;P&gt;&lt;STRONG&gt;&lt;A href="http://usa.autodesk.com/adsk/servlet/index?siteID=123112&amp;amp;id=770215#vbatonet" target="_blank"&gt;AutoCAD VBA to VB.NET Migration Basics&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2012 05:47:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-switch-between-multiple-open-documents/m-p/3725112#M52140</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2012-12-06T05:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to switch between multiple open documents?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-switch-between-multiple-open-documents/m-p/3856640#M52142</link>
      <description>&lt;P&gt;I watched the video, but as far as I can tell he only shows how to get the event flag showing that the user has switched the active document.&amp;nbsp; He doesn't show the code for how to switch focus from one open drawing to another already open drawing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My goal is to perform various actions on a subset of drawings, which will vary from project to project.&amp;nbsp; All of the examples I have looked at show how to open, change, then close specific drawings by file name.&amp;nbsp; I don't want to hard-code the file names into my .net project, I just want to perform an action on files already open, one-by-one.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2013 15:08:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-switch-between-multiple-open-documents/m-p/3856640#M52142</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-04-11T15:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to switch between multiple open documents?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-switch-between-multiple-open-documents/m-p/3856819#M52143</link>
      <description>&lt;P&gt;Note:&lt;/P&gt;&lt;P&gt;If you execute the following code without the CommandsFlags.Session after it switches to another document the code will not continue&amp;nbsp;until to you activate the document that the command was started in. So you have Drawing1-Drawing10 and Drawing1 is active. Without the Sessions flag Drawing2 will become active and your no longer in the "Document Context" of Drawing1. Once you switch back to Drawing1 then the code will continue executing and Drawing3 would become active, etc........&lt;/P&gt;&lt;P&gt;By specifying Sessions flag it will execute in "Application context" and only pause until the alert box is closed so to modify any of the documents you would have to explicitly lock them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for not giving a more complete exampe but after I write&amp;nbsp;about 10 lines of VB I start to throw up in my mouth.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        &amp;lt;CommandMethod("MyCommand", CommandFlags.Session)&amp;gt; _
        Public Sub MyCommand() ' This method can have any name
            Dim docMgr As DocumentCollection = Application.DocumentManager
            For Each doc As Document In docMgr
                Application.DocumentManager.MdiActiveDocument = doc
                Application.ShowAlertDialog(doc.Name)
            Next
        End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2013 17:03:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-switch-between-multiple-open-documents/m-p/3856819#M52143</guid>
      <dc:creator>jeff</dc:creator>
      <dc:date>2013-04-11T17:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to switch between multiple open documents?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-switch-between-multiple-open-documents/m-p/3856954#M52144</link>
      <description>&lt;P&gt;You also need to enable switching:&lt;/P&gt;
&lt;PRE class="vb geshi" style="font-family: monospace;"&gt;Application.DocumentManager.DocumentActivationEnabled = &lt;SPAN style="color: #00c2ff; font-weight: bold;"&gt;True&lt;/SPAN&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Apr 2013 18:05:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-switch-between-multiple-open-documents/m-p/3856954#M52144</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2013-04-11T18:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to switch between multiple open documents?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-switch-between-multiple-open-documents/m-p/5464249#M52145</link>
      <description>&lt;P&gt;Hi Alex do you think you could take a look at this thread?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://forums.autodesk.com/t5/net/change-activedocument/m-p/5464181/highlight/false#M42929" target="_blank"&gt;http://forums.autodesk.com/t5/net/change-activedocument/m-p/5464181/highlight/false#M42929&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems to be in the same vain as this thread but the same solution doesn't work....&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jan 2015 17:17:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-switch-between-multiple-open-documents/m-p/5464249#M52145</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-01-09T17:17:01Z</dc:date>
    </item>
  </channel>
</rss>

