Centering plots with VBA

Centering plots with VBA

Anonymous
Not applicable
272 Views
0 Replies
Message 1 of 1

Centering plots with VBA

Anonymous
Not applicable



To Center My Plot i need to run my project twice

What do i Wrong


1)

Sub test()


Dim sConfig As AcadPlotConfiguration

ThisDrawing.Regen acAllViewports

Set sConfig = ThisDrawing.ActiveLayout


   sConfig.PaperUnits = acInches

   sConfig.CenterPlot = True

   sConfig.RefreshPlotDeviceInfo


 ThisDrawing.Regen acAllViewports

 ThisDrawing.Plot.DisplayPlotPreview acFullPreview '

End Sub

2)

Sub test()

Dim Layouts As AcadLayouts, Layout As Acadlayout

Dim IsCentered As String


Set Layouts = ThisDrawing.Layouts


   ' Toggle centered state for Layout1

   Layouts("Layout1").PlotType = acExtents

   Layouts("Layout1").CenterPlot = Not (Layouts("Layout1").CenterPlot)


 ThisDrawing.Regen acAllViewports

 ThisDrawing.Plot.DisplayPlotPreview acFullPreview

End Sub


3)

  Dim strValue As String

  Dim sLayout As AcadPlotConfiguration

  Dim varWidth As Double

  Dim varHeight As Double

  Dim dblpt(0 To 2) As Double


    Set sLayout = ThisDrawing.ActiveLayout


    sLayout.GetPaperSize varWidth, varHeight

  ''The center of that paper

    dblpt(0) = varHeight / 2: dblpt(1) = varWidth / 2: dblpt(2) = 0#

    sLayout.PlotType = acExtents


ThisDrawing.Regen acAllViewports

 ThisDrawing.Plot.DisplayPlotPreview acFullPreview





0 Likes
273 Views
0 Replies
Replies (0)