Target Example

Using Programming Languages other than VBA

Sub Example_Target()
	' This example changes the target for a model space viewport.

	' Create a new model space viewport
	Dim viewportObj As AcadViewport
	Set viewportObj = ThisDrawing.Viewports.Add("NewViewport")

	' Add a circle
	Dim circleObj As AcadCircle
	Dim center(0 To 2) As Double
	Dim radius As Double
	center(0) = 0: center(1) = 0: center(2) = 0
	radius = 1
	Set circleObj = ThisDrawing.ModelSpace.AddCircle(center, radius)

	' Find the current target
	Dim currTarget As Variant
	currTarget = viewportObj.target
	MsgBox "The current target is " & viewportObj.target(0) & ", " & viewportObj.target(1) & ", " & viewportObj.target(2), , "Target Example"

	' Change the target
	Dim newTarget(0 To 2) As Double
	newTarget(0) = 2#: newTarget(1) = 2#: newTarget(2) = 0
	viewportObj.target = newTarget
	ThisDrawing.ActiveViewport = viewportObj
	ThisDrawing.Regen acAllViewports
	MsgBox "The new target is " & viewportObj.target(0) & ", " & viewportObj.target(1) & ", " & viewportObj.target(2), , "Target Example"
   
End Sub

 

   Comments?