Make Another Tiled Viewport Current
From AutoCAD ActiveX
You enter points and select objects in the current viewport. To make a viewport current, use the ActiveViewport property.
You can iterate through existing viewports to find a particular viewport. To do this, first identify the name of the viewport configuration on which the desired viewport resides using the Name property. Additionally, if the viewport configuration has been split, each individual viewport on the configuration can be identified through the LowerLeftCorner and UpperRightCorner properties.
The LowerLeftCorner and UpperRightCorner properties represent the graphic placement of the viewport on the display. These properties are defined as follows (using a four-way split as an example):
- Viewport 1-LowerLeftCorner = (0, .5), UpperRightCorner = (.5, 1)
- Viewport 2-LowerLeftCorner = (.5, .5), UpperRightCorner = (1, 1)
- Viewport 3-LowerLeftCorner = (0, 0), UpperRightCorner = (.5, .5)
- Viewport 4-LowerLeftCorner = (.5, 0), UpperRightCorner = (1, .5)
Split a viewport, then iterate through the windows
This example splits a viewport into four windows. It then iterates through all the viewports in the drawing and displays the viewport name and the lower-left and upper-right corner for each viewport.
Sub Ch3_IteratingViewportWindows()
' Create a new viewport and make it active
Dim vportObj As AcadViewport
Set vportObj = ThisDrawing.Viewports.Add("TEST_VIEWPORT")
ThisDrawing.ActiveViewport = vportObj
' Split vport into 4 windowsvportObj.Split acViewport4' Iterate through the viewports,' highlighting each viewport and displaying' the upper right and lower left corners' for each.Dim vport As AcadViewportDim LLCorner As VariantDim URCorner As VariantFor Each vport In ThisDrawing.ViewportsThisDrawing.ActiveViewport = vportLLCorner = vport.LowerLeftCornerURCorner = vport.UpperRightCornerMsgBox "Viewport: " & vport.Name & " is now active." & _vbCrLf & "Lower left corner: " & _LLCorner(0) & ", " & LLCorner(1) & vbCrLf & _"Upper right corner: " & _URCorner(0) & ", " & URCorner(1)Next vportEnd Sub