CenterPlot Example

Using Programming Languages other than VBA

Sub Example_CenterPlot()
	' This example will access the Layouts collection for the current drawing
	' and display whether the plot for this layout is to be centered on the media.
	' It will then toggle the state of CenterPlot for "Layout1" and re-display the
	' CenterPlot state for each Layout.

	Dim Layouts As AcadLayouts, Layout As ACADLayout
	Dim msg As String
	Dim IsCentered As String

	' Get layouts collection from document object
	Set Layouts = ThisDrawing.Layouts

	' Display current layout information

	' Toggle centered state for Layout1
	Layouts("Layout1").PlotType = acDisplay
	Layouts("Layout1").CenterPlot = Not (Layouts("Layout1").CenterPlot)
	ThisDrawing.Regen acAllViewports

	' Display new layout information

	Exit Sub

	msg = ""	' Clear message

	' Determine whether this layout is centered on the media during a plot
	For Each Layout In Layouts
		IsCentered = IIf(Layout.CenterPlot, " are centered ", " are not centered ")
		' Format for display
		msg = msg & "Objects for " & & IsCentered & "on the media during a plot." & vbCrLf

	' Display layout information
	MsgBox msg

End Sub