<?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 Get Frozen Layers in Floating Viewport in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/get-frozen-layers-in-floating-viewport/m-p/5952607#M37693</link>
    <description>&lt;P&gt;I have looked over a quite a few posts on this subject but&amp;nbsp;am still running into problems.&amp;nbsp; I want to find all frozen layers in each floating viewport of each paper space layout.&amp;nbsp; I have put together some code below that that attempts to display these layers.&amp;nbsp; However, it appears that the layers displayed are those of the paper space layout and not of the model space of each floating viewport.&amp;nbsp; Could someone point out what I may be missing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; Private Sub ShowFrozenLayersInFloatingViewports()

        Try
            Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            Dim ed As Editor = doc.Editor
            Dim dwg As Database = HostApplicationServices.WorkingDatabase

            Using trans As Transaction = dwg.TransactionManager.StartTransaction()

                Dim LayoutDict As DBDictionary = CType(trans.GetObject(dwg.LayoutDictionaryId, OpenMode.ForRead), DBDictionary)
                For Each entr As DictionaryEntry In LayoutDict
                    If entr.Key.ToString().ToUpper() &amp;lt;&amp;gt; "MODEL" Then

                        Dim myLayout As Layout = CType(trans.GetObject(entr.Value, OpenMode.ForWrite), Layout)
                        Try
                            myLayout.Initialize()
                        Catch ex As Autodesk.AutoCAD.Runtime.Exception

                        End Try

                        Dim colViewportIDs As ObjectIdCollection = myLayout.GetViewports()

                        For Each objID As ObjectId In colViewportIDs
                            Dim sLayer As String = ""
                            Dim vp As Viewport = DirectCast(trans.GetObject(objID, OpenMode.ForWrite), Viewport)
                            Dim vpFrozenLayerIDs As ObjectIdCollection = vp.GetFrozenLayers
                            For Each layerID As ObjectId In vpFrozenLayerIDs
                                Dim myLayerTable As LayerTable = trans.GetObject(dwg.LayerTableId, OpenMode.ForRead)
                                Dim myLayer As LayerTableRecord = layerID.GetObject(OpenMode.ForRead)
                                sLayer = sLayer &amp;amp; myLayer.Name &amp;amp; vbCrLf
                            Next
                            MsgBox("Frozen Layers in " &amp;amp; myLayout.LayoutName &amp;amp; vbCrLf &amp;amp; "--------------------------" &amp;amp; vbCrLf &amp;amp; sLayer)
                        Next
                    End If
                Next
                trans.Commit()
            End Using 'trans

        Catch ex As Autodesk.AutoCAD.Runtime.Exception
            Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
            ed.WriteMessage(ControlChars.CrLf &amp;amp; "Error {0} " &amp;amp; ControlChars.CrLf, ex)
            ed.WriteMessage(ex.StackTrace)
        End Try

    End Sub&lt;/PRE&gt;</description>
    <pubDate>Tue, 15 Dec 2015 18:06:45 GMT</pubDate>
    <dc:creator>ChrisPicklesimer</dc:creator>
    <dc:date>2015-12-15T18:06:45Z</dc:date>
    <item>
      <title>Get Frozen Layers in Floating Viewport</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-frozen-layers-in-floating-viewport/m-p/5952607#M37693</link>
      <description>&lt;P&gt;I have looked over a quite a few posts on this subject but&amp;nbsp;am still running into problems.&amp;nbsp; I want to find all frozen layers in each floating viewport of each paper space layout.&amp;nbsp; I have put together some code below that that attempts to display these layers.&amp;nbsp; However, it appears that the layers displayed are those of the paper space layout and not of the model space of each floating viewport.&amp;nbsp; Could someone point out what I may be missing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; Private Sub ShowFrozenLayersInFloatingViewports()

        Try
            Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            Dim ed As Editor = doc.Editor
            Dim dwg As Database = HostApplicationServices.WorkingDatabase

            Using trans As Transaction = dwg.TransactionManager.StartTransaction()

                Dim LayoutDict As DBDictionary = CType(trans.GetObject(dwg.LayoutDictionaryId, OpenMode.ForRead), DBDictionary)
                For Each entr As DictionaryEntry In LayoutDict
                    If entr.Key.ToString().ToUpper() &amp;lt;&amp;gt; "MODEL" Then

                        Dim myLayout As Layout = CType(trans.GetObject(entr.Value, OpenMode.ForWrite), Layout)
                        Try
                            myLayout.Initialize()
                        Catch ex As Autodesk.AutoCAD.Runtime.Exception

                        End Try

                        Dim colViewportIDs As ObjectIdCollection = myLayout.GetViewports()

                        For Each objID As ObjectId In colViewportIDs
                            Dim sLayer As String = ""
                            Dim vp As Viewport = DirectCast(trans.GetObject(objID, OpenMode.ForWrite), Viewport)
                            Dim vpFrozenLayerIDs As ObjectIdCollection = vp.GetFrozenLayers
                            For Each layerID As ObjectId In vpFrozenLayerIDs
                                Dim myLayerTable As LayerTable = trans.GetObject(dwg.LayerTableId, OpenMode.ForRead)
                                Dim myLayer As LayerTableRecord = layerID.GetObject(OpenMode.ForRead)
                                sLayer = sLayer &amp;amp; myLayer.Name &amp;amp; vbCrLf
                            Next
                            MsgBox("Frozen Layers in " &amp;amp; myLayout.LayoutName &amp;amp; vbCrLf &amp;amp; "--------------------------" &amp;amp; vbCrLf &amp;amp; sLayer)
                        Next
                    End If
                Next
                trans.Commit()
            End Using 'trans

        Catch ex As Autodesk.AutoCAD.Runtime.Exception
            Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
            ed.WriteMessage(ControlChars.CrLf &amp;amp; "Error {0} " &amp;amp; ControlChars.CrLf, ex)
            ed.WriteMessage(ex.StackTrace)
        End Try

    End Sub&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Dec 2015 18:06:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-frozen-layers-in-floating-viewport/m-p/5952607#M37693</guid>
      <dc:creator>ChrisPicklesimer</dc:creator>
      <dc:date>2015-12-15T18:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: Get Frozen Layers in Floating Viewport</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-frozen-layers-in-floating-viewport/m-p/5952777#M37694</link>
      <description>&lt;P&gt;I can't code in AutoCAD right now.&lt;BR /&gt;The first VpId is not one of you're Floating Layout Vp, it's the&amp;nbsp; paper space viewport.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;You might check the other Viewport Id's for each Layout, they should all be different id's.&lt;BR /&gt;If not , set the layout current before GetViewports().&lt;/P&gt;&lt;P&gt;LayoutManager layoutMgr = LayoutManager.Current;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;Layout theLayout = (Layout)tr.GetObject(layoutId, OpenMode.ForRead);&lt;/P&gt;&lt;P&gt;LayoutManager.Current.CurrentLayout = theLayout.Layoutname;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;When that solves the issue then a workaroud is to retrieve the VpId's from the Layout BlockTableRecord and again skip the first one.&lt;BR /&gt;BlockTableRecord layoutBtr = (BlockTableRecord)tr.GetObject(theLayout.BlockTableRecordId,...)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2015 19:37:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-frozen-layers-in-floating-viewport/m-p/5952777#M37694</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2015-12-15T19:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: Get Frozen Layers in Floating Viewport</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-frozen-layers-in-floating-viewport/m-p/5956188#M37695</link>
      <description>&lt;P&gt;Once I set layout current and ignored the first viewport ID I was able to get the expected results.&amp;nbsp; Thanks for the help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2015 15:29:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-frozen-layers-in-floating-viewport/m-p/5956188#M37695</guid>
      <dc:creator>ChrisPicklesimer</dc:creator>
      <dc:date>2015-12-17T15:29:23Z</dc:date>
    </item>
  </channel>
</rss>

