Message 1 of 2
Viewport size
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
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.
Because of this i want to resize my viewport to the new scale of my 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.
So the question is; why does the viewport border does not update after changing the dimensions?
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 <> "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 < 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