<?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: switching layout in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/switching-layout/m-p/2548681#M69250</link>
    <description>&lt;DIV id="jive-html-wrapper-div"&gt;
&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;Thanks, but my problem is in the line &lt;BR /&gt;
"&lt;STRONG&gt;&lt;EM&gt;MyLayoutManager.CurrentLayout = MyLayout.LayoutName"&lt;/EM&gt;&lt;/STRONG&gt;: &lt;BR /&gt;
i dont know because but it dont work.&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;It make "Error handler re-entered" &lt;BR /&gt;
error.&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;&amp;lt;cadmeup&amp;gt; ha scritto nel messaggio &lt;/FONT&gt;&lt;A&gt;&lt;BR /&gt;
href="news:6246398@discussion.autodesk.com"&amp;gt;&lt;FONT size="2"&gt;&lt;BR /&gt;
face=Arial&amp;gt;news:6246398@discussion.autodesk.com&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size="2"&gt;&lt;BR /&gt;
face=Arial&amp;gt;...&lt;/FONT&gt;&lt;/DIV&gt;&lt;FONT size="2" face="Arial"&gt;You can try this, it uses &lt;BR /&gt;
AutoCAD interop so make sure you reference those assemblies. I replaced/removed &lt;BR /&gt;
lines from your code, you can see the differences here:&lt;BR /&gt;{code}&lt;BR /&gt;Dim Db As &lt;BR /&gt;
Database = MyDocument.Database&lt;BR /&gt;Dim Tr As Transaction = &lt;BR /&gt;
Db.TransactionManager.StartTransaction&lt;BR /&gt;Dim MyLayoutManager As &lt;BR /&gt;
Autodesk.AutoCAD.DatabaseServices.LayoutManager = LayoutManager.Current()&lt;BR /&gt;Dim &lt;BR /&gt;
acadApp As AcadApplication = &lt;BR /&gt;
Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication&lt;BR /&gt;&lt;BR /&gt;Try&lt;BR /&gt;Dim &lt;BR /&gt;
LayoutDict As DBDictionary = Tr.GetObject(Db.LayoutDictionaryId, &lt;BR /&gt;
OpenMode.ForRead)&lt;BR /&gt;For Each id As DictionaryEntry In LayoutDict&lt;BR /&gt;Dim &lt;BR /&gt;
MyLayout As Layout = CType(Tr.GetObject(id.Value, OpenMode.ForRead), &lt;BR /&gt;
Layout)&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;MyLayoutManager.CurrentLayout = &lt;BR /&gt;
MyLayout.LayoutName&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;acadApp.ZoomExtents()&lt;BR /&gt;Next&lt;BR /&gt;Finally&lt;BR /&gt;Tr.Commit()&lt;BR /&gt;End &lt;BR /&gt;
Try&lt;BR /&gt;{code}&lt;/FONT&gt;
&lt;/DIV&gt;</description>
    <pubDate>Tue, 01 Sep 2009 09:25:34 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2009-09-01T09:25:34Z</dc:date>
    <item>
      <title>switching layout</title>
      <link>https://forums.autodesk.com/t5/net-forum/switching-layout/m-p/2548679#M69248</link>
      <description>This dont work when it meet a not used paperspace layout.&lt;BR /&gt;
Can you help me?&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;BR /&gt;
Public Sub MyZoom (MyDocument)&lt;BR /&gt;
&lt;BR /&gt;
Dim Db As Database = MyDocument.Database&lt;BR /&gt;
Dim Tr As Transaction = Db.TransactionManager.StartTransaction&lt;BR /&gt;
Dim MyLayoutManager As Autodesk.AutoCAD.DatabaseServices.LayoutManager = &lt;BR /&gt;
LayoutManager.Current&lt;BR /&gt;
Try&lt;BR /&gt;
Dim LayoutDict As DBDictionary = Tr.GetObject(Db.LayoutDictionaryId, &lt;BR /&gt;
OpenMode.ForRead)&lt;BR /&gt;
For Each id As DictionaryEntry In LayoutDict&lt;BR /&gt;
Dim MyLayout As Layout = DirectCast(Tr.GetObject(DirectCast(id.Value, &lt;BR /&gt;
ObjectId), OpenMode.ForRead), Layout)&lt;BR /&gt;
MyLayoutManager.CurrentLayout = MyLayout.LayoutName&lt;BR /&gt;
MyDocument.SendStringToExecute("_zoom" &amp;amp; vbCr &amp;amp; "_e" &amp;amp; vbCr, False, False, &lt;BR /&gt;
False)&lt;BR /&gt;
Next&lt;BR /&gt;
Tr.Commit()&lt;BR /&gt;
Finally&lt;BR /&gt;
Tr.Dispose()&lt;BR /&gt;
End Try&lt;BR /&gt;
&lt;BR /&gt;
End Sub</description>
      <pubDate>Mon, 31 Aug 2009 08:57:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/switching-layout/m-p/2548679#M69248</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-08-31T08:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: switching layout</title>
      <link>https://forums.autodesk.com/t5/net-forum/switching-layout/m-p/2548680#M69249</link>
      <description>You can try this, it uses AutoCAD interop so make sure you reference those assemblies. I replaced/removed lines from your code, you can see the differences here:&lt;BR /&gt;
{code}&lt;BR /&gt;
Dim Db As Database = MyDocument.Database&lt;BR /&gt;
Dim Tr As Transaction = Db.TransactionManager.StartTransaction&lt;BR /&gt;
Dim MyLayoutManager As Autodesk.AutoCAD.DatabaseServices.LayoutManager = LayoutManager.Current()&lt;BR /&gt;
Dim acadApp As AcadApplication = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication&lt;BR /&gt;
&lt;BR /&gt;
Try&lt;BR /&gt;
	Dim LayoutDict As DBDictionary = Tr.GetObject(Db.LayoutDictionaryId, OpenMode.ForRead)&lt;BR /&gt;
	For Each id As DictionaryEntry In LayoutDict&lt;BR /&gt;
		Dim MyLayout As Layout = CType(Tr.GetObject(id.Value, OpenMode.ForRead), Layout)&lt;BR /&gt;
		MyLayoutManager.CurrentLayout = MyLayout.LayoutName&lt;BR /&gt;
		acadApp.ZoomExtents()&lt;BR /&gt;
	Next&lt;BR /&gt;
Finally&lt;BR /&gt;
	Tr.Commit()&lt;BR /&gt;
End Try&lt;BR /&gt;
{code}</description>
      <pubDate>Mon, 31 Aug 2009 23:49:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/switching-layout/m-p/2548680#M69249</guid>
      <dc:creator>cadMeUp</dc:creator>
      <dc:date>2009-08-31T23:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: switching layout</title>
      <link>https://forums.autodesk.com/t5/net-forum/switching-layout/m-p/2548681#M69250</link>
      <description>&lt;DIV id="jive-html-wrapper-div"&gt;
&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;Thanks, but my problem is in the line &lt;BR /&gt;
"&lt;STRONG&gt;&lt;EM&gt;MyLayoutManager.CurrentLayout = MyLayout.LayoutName"&lt;/EM&gt;&lt;/STRONG&gt;: &lt;BR /&gt;
i dont know because but it dont work.&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;It make "Error handler re-entered" &lt;BR /&gt;
error.&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;&amp;lt;cadmeup&amp;gt; ha scritto nel messaggio &lt;/FONT&gt;&lt;A&gt;&lt;BR /&gt;
href="news:6246398@discussion.autodesk.com"&amp;gt;&lt;FONT size="2"&gt;&lt;BR /&gt;
face=Arial&amp;gt;news:6246398@discussion.autodesk.com&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size="2"&gt;&lt;BR /&gt;
face=Arial&amp;gt;...&lt;/FONT&gt;&lt;/DIV&gt;&lt;FONT size="2" face="Arial"&gt;You can try this, it uses &lt;BR /&gt;
AutoCAD interop so make sure you reference those assemblies. I replaced/removed &lt;BR /&gt;
lines from your code, you can see the differences here:&lt;BR /&gt;{code}&lt;BR /&gt;Dim Db As &lt;BR /&gt;
Database = MyDocument.Database&lt;BR /&gt;Dim Tr As Transaction = &lt;BR /&gt;
Db.TransactionManager.StartTransaction&lt;BR /&gt;Dim MyLayoutManager As &lt;BR /&gt;
Autodesk.AutoCAD.DatabaseServices.LayoutManager = LayoutManager.Current()&lt;BR /&gt;Dim &lt;BR /&gt;
acadApp As AcadApplication = &lt;BR /&gt;
Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication&lt;BR /&gt;&lt;BR /&gt;Try&lt;BR /&gt;Dim &lt;BR /&gt;
LayoutDict As DBDictionary = Tr.GetObject(Db.LayoutDictionaryId, &lt;BR /&gt;
OpenMode.ForRead)&lt;BR /&gt;For Each id As DictionaryEntry In LayoutDict&lt;BR /&gt;Dim &lt;BR /&gt;
MyLayout As Layout = CType(Tr.GetObject(id.Value, OpenMode.ForRead), &lt;BR /&gt;
Layout)&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;MyLayoutManager.CurrentLayout = &lt;BR /&gt;
MyLayout.LayoutName&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;acadApp.ZoomExtents()&lt;BR /&gt;Next&lt;BR /&gt;Finally&lt;BR /&gt;Tr.Commit()&lt;BR /&gt;End &lt;BR /&gt;
Try&lt;BR /&gt;{code}&lt;/FONT&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 01 Sep 2009 09:25:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/switching-layout/m-p/2548681#M69250</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-09-01T09:25:34Z</dc:date>
    </item>
    <item>
      <title>Re: switching layout</title>
      <link>https://forums.autodesk.com/t5/net-forum/switching-layout/m-p/2548682#M69251</link>
      <description>It might help to see the rest of your code, specifically where the sub is being called.&lt;BR /&gt;
I get an error and crash when calling your MyZoom sub in a command sub defined with the "CommandFlags.Session" flag:&lt;BR /&gt;
{code}&lt;BR /&gt;
    &amp;lt;CommandMethod("LAYOUTZM", CommandFlags.Session)&amp;gt; _&lt;BR /&gt;
    Public Sub LAYOUTZM()&lt;BR /&gt;
        MyZoom(AcApp.DocumentManager.MdiActiveDocument)&lt;BR /&gt;
    End Sub&lt;BR /&gt;
{code}</description>
      <pubDate>Tue, 01 Sep 2009 23:22:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/switching-layout/m-p/2548682#M69251</guid>
      <dc:creator>cadMeUp</dc:creator>
      <dc:date>2009-09-01T23:22:36Z</dc:date>
    </item>
  </channel>
</rss>

