<?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 Viewport size in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/viewport-size/m-p/8218500#M24947</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lately i've been working on a VB.net script to loop through all my large viewports and do a zoomextents on the content of this viewport. during this zoomextents the new scale will round up. for example 1:21,433 will be 1:30.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Because of this i want to resize my viewport to the&amp;nbsp;new scale of my&amp;nbsp;viewport with some space around. When i apply the code below (so resize the viewport with the vp.width and vp.height) the visible border of my viewport will not change in the lay-out. though when i look in the viewport properties itself the dimensions are changed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the question is; why does the viewport border does not update after changing the dimensions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Module PaperSpace
    Public Sub PrepareLayouts()
        Dim Newdoc As Document = Application.DocumentManager.MdiActiveDocument
        Dim db As Database = Newdoc.Database
        Dim ed As Editor = Newdoc.Editor
        Dim lm As LayoutManager = LayoutManager.Current

        Using tr As Transaction = db.TransactionManager.StartTransaction()
            'Loop thru the layouts making each one active
            Dim layoutDict As DBDictionary = db.LayoutDictionaryId.GetObject(OpenMode.ForRead)
            Dim modelMin2D As Point2d = New Point2d(db.Extmin.X, db.Extmin.Y)
            Dim modelMax2D As Point2d = New Point2d(db.Extmax.X, db.Extmax.Y)
            Dim modelWidth As Double = db.Extmax.X - db.Extmin.X
            Dim modelHeight As Double = db.Extmax.Y - db.Extmin.Y

            For Each de As DBDictionaryEntry In layoutDict
                Dim layout As Layout = de.Value.GetObject(OpenMode.ForRead)
                Dim layoutName As String = layout.LayoutName
                If layoutName &amp;lt;&amp;gt; "Model" Then
                    'Loop thru layout viewports for zoom extents
                    lm.CurrentLayout = layoutName
                    Dim vpIdCol As ObjectIdCollection = layout.GetViewports()
                    For Each vpId As ObjectId In vpIdCol
                        Dim vp As Viewport = vpId.GetObject(OpenMode.ForWrite)
                        If (vp.Layer = "Viewport" Or vp.Layer = "Viewport Visible") And layout.PlotPaperSize.X / vp.Width &amp;lt; 1 Then
                            Dim vpWidth As Double = vp.Width
                            Dim vpHeight As Double = vp.Height
                            Dim scale As Integer = DefineScale(modelWidth / vpWidth)
                            vp.UpgradeOpen()
                            ''Zoom viewport to extents of model
                            vp.Width = modelWidth / scale
                            vp.Height = modelHeight / scale
                            vp.CenterPoint = New Point3d(vp.CenterPoint.X, vp.CenterPoint.Y + 15, vp.CenterPoint.Z)
                            vp.UpdateDisplay()

                            vp.Locked = False
                            vp.ViewCenter = modelMin2D + ((modelMax2D - modelMin2D) * 0.5)
                            vp.CustomScale = 1 / scale
                            vp.Locked = True

                            ''Perform actions on viewport layers 
                            VPLayerFreeze(tr, layoutName, vp)
                            VPLayerGrey(tr, layoutName, vp)
                        End If
                    Next
                End If
            Next
            tr.Commit()
            Newdoc.Editor.Regen()
            lm.CurrentLayout = "Model"
        End Using
    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Aug 2018 06:31:14 GMT</pubDate>
    <dc:creator>p.zwiers</dc:creator>
    <dc:date>2018-08-23T06:31:14Z</dc:date>
    <item>
      <title>Viewport size</title>
      <link>https://forums.autodesk.com/t5/net-forum/viewport-size/m-p/8218500#M24947</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lately i've been working on a VB.net script to loop through all my large viewports and do a zoomextents on the content of this viewport. during this zoomextents the new scale will round up. for example 1:21,433 will be 1:30.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Because of this i want to resize my viewport to the&amp;nbsp;new scale of my&amp;nbsp;viewport with some space around. When i apply the code below (so resize the viewport with the vp.width and vp.height) the visible border of my viewport will not change in the lay-out. though when i look in the viewport properties itself the dimensions are changed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the question is; why does the viewport border does not update after changing the dimensions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Module PaperSpace
    Public Sub PrepareLayouts()
        Dim Newdoc As Document = Application.DocumentManager.MdiActiveDocument
        Dim db As Database = Newdoc.Database
        Dim ed As Editor = Newdoc.Editor
        Dim lm As LayoutManager = LayoutManager.Current

        Using tr As Transaction = db.TransactionManager.StartTransaction()
            'Loop thru the layouts making each one active
            Dim layoutDict As DBDictionary = db.LayoutDictionaryId.GetObject(OpenMode.ForRead)
            Dim modelMin2D As Point2d = New Point2d(db.Extmin.X, db.Extmin.Y)
            Dim modelMax2D As Point2d = New Point2d(db.Extmax.X, db.Extmax.Y)
            Dim modelWidth As Double = db.Extmax.X - db.Extmin.X
            Dim modelHeight As Double = db.Extmax.Y - db.Extmin.Y

            For Each de As DBDictionaryEntry In layoutDict
                Dim layout As Layout = de.Value.GetObject(OpenMode.ForRead)
                Dim layoutName As String = layout.LayoutName
                If layoutName &amp;lt;&amp;gt; "Model" Then
                    'Loop thru layout viewports for zoom extents
                    lm.CurrentLayout = layoutName
                    Dim vpIdCol As ObjectIdCollection = layout.GetViewports()
                    For Each vpId As ObjectId In vpIdCol
                        Dim vp As Viewport = vpId.GetObject(OpenMode.ForWrite)
                        If (vp.Layer = "Viewport" Or vp.Layer = "Viewport Visible") And layout.PlotPaperSize.X / vp.Width &amp;lt; 1 Then
                            Dim vpWidth As Double = vp.Width
                            Dim vpHeight As Double = vp.Height
                            Dim scale As Integer = DefineScale(modelWidth / vpWidth)
                            vp.UpgradeOpen()
                            ''Zoom viewport to extents of model
                            vp.Width = modelWidth / scale
                            vp.Height = modelHeight / scale
                            vp.CenterPoint = New Point3d(vp.CenterPoint.X, vp.CenterPoint.Y + 15, vp.CenterPoint.Z)
                            vp.UpdateDisplay()

                            vp.Locked = False
                            vp.ViewCenter = modelMin2D + ((modelMax2D - modelMin2D) * 0.5)
                            vp.CustomScale = 1 / scale
                            vp.Locked = True

                            ''Perform actions on viewport layers 
                            VPLayerFreeze(tr, layoutName, vp)
                            VPLayerGrey(tr, layoutName, vp)
                        End If
                    Next
                End If
            Next
            tr.Commit()
            Newdoc.Editor.Regen()
            lm.CurrentLayout = "Model"
        End Using
    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 06:31:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/viewport-size/m-p/8218500#M24947</guid>
      <dc:creator>p.zwiers</dc:creator>
      <dc:date>2018-08-23T06:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: Viewport size</title>
      <link>https://forums.autodesk.com/t5/net-forum/viewport-size/m-p/8234435#M24948</link>
      <description>&lt;P&gt;Can you please share the test drawing ?, and also definitions for these methods&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;VPLayerFreeze(tr, layoutName, vp)&lt;/LI&gt;
&lt;LI&gt;VPLayerGrey(tr, layoutName, vp)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;if this applicable to your routine. I would like to investigate the problem.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 05:36:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/viewport-size/m-p/8234435#M24948</guid>
      <dc:creator>moogalm</dc:creator>
      <dc:date>2018-08-30T05:36:19Z</dc:date>
    </item>
  </channel>
</rss>

