Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I'm trying to create viewports in layouts from modelspace. I can't seem to get the zoom window working. This is my code for changing the default viewport to the page size, activating mspace and then I want to zoom on a rectangle, but this is not working, it just takes center of modelspace everytime. Am I doing something wrong?
Sub CreateViewPort(newdwg As AcadDocument, a As Integer) ' Set the active space to paper space newdwg.ActiveSpace = acPaperSpace ' get / add a layout Dim layout As AcadLayout Set layout = newdwg.Layouts.Item(a) ' .Add("Sheet " & 1) ' activate the first layout newdwg.ActiveLayout = layout ' get the standard created viewport Dim vp As AcadPViewport Set vp = layout.Block.Item(1) ' get the paper height and width Dim pHeight As Double, pWidth As Double Call layout.GetPaperSize(pWidth, pHeight) ' set viewport height width and scale vp.Height = pWidth vp.Width = pHeight vp.StandardScale = acVp1_20 ' activate the viewport, unlock the display and activate the modelspace vp.Display True newdwg.MSpace = True vp.DisplayLocked = False ' Set newVport current newdwg.ActivePViewport = vp ' find the coordinates where we want to zoom at Dim p1(2) As Double p1(0) = (8410 * a): p1(1) = 0: p1(2) = 0 Dim p2(2) As Double p2(0) = (8410 * (a + 1)): p2(1) = 5840: p2(2) = 0 ZoomWindow p1, p2 ' Turn model space editing off newdwg.MSpace = False ' ZoomExtents in paperspace ZoomExtents ' lock the vp vp.DisplayLocked = True ' fix the **** newdwg.Regen acAllViewports End Sub
Solved! Go to Solution.