ViewportOn Example

Using Programming Languages other than VBA

Sub Example_ViewportOn()
	' This example creates two new paper space viewports.
	' It then checks the status of the viewports.

	Dim pviewportObj1 As AcadPViewport
	Dim pviewportObj2 As AcadPViewport
	Dim center(0 To 2) As Double
	Dim width As Double
	Dim height As Double

	' Define the paper space viewport
	center(0) = 3: center(1) = 3: center(2) = 0
	width = 10
	height = 10

	' Change from model space to paper space
	ThisDrawing.ActiveSpace = acPaperSpace

	' Create the paper space viewports
	Set pviewportObj1 = ThisDrawing.PaperSpace.AddPViewport(center, width, height)
	center(0) = 8: center(1) = 8: center(2) = 0
	width = 10
	height = 10
	Set pviewportObj2 = ThisDrawing.PaperSpace.AddPViewport(center, width, height)

	' Before making a paper space viewport active,
	' the mspace property needs to be True
	pviewportObj1.DISPLAY (True)
	ThisDrawing.mspace = True
	ThisDrawing.ActivePViewport = pviewportObj1
	ThisDrawing.Regen acAllViewports

	MsgBox "pviewportObj1 is " & (IIf(pviewportObj1.ViewportOn, "on.", "not on.")) & vbCrLf & _
		 "pviewportObj2 is " & (IIf(pviewportObj2.ViewportOn, "on.", "not on."))

	' Now turn on pviewportObj2 as well
	pviewportObj2.DISPLAY (True)
	MsgBox "pviewportObj1 is " & (IIf(pviewportObj1.ViewportOn, "on.", "not on.")) & vbCrLf & _
		 "pviewportObj2 is " & (IIf(pviewportObj2.ViewportOn, "on.", "not on."))

End Sub

 

   Comments?