Jump to content

I’m confused. (VBA Page Layout question)


TroutKing

Recommended Posts

The code below actually works. It sets up my acLayout limits and then sets up a new page for me in the Page Setup Manager.

 

However, it sets up my acLayout limits on the paperspace tab (which I want) but it creates the new Page Manager page on the modelspace tab (which I don’t want).

 

I can’t seem to see any reason for this to take place.

 

Can any of you plotting gurus help me understand what I did wrong and how I can create the new page in the Page Setup Manager in my paperspace tab to go along with its setup?

 

Option Explicit

Public Sub CreatePageSetup()

GoGetCanonicalMediaNames
Create_24x36
'Create_11x17

MsgBox "            DONE"

End Sub

Private Sub Create_24x36()

******************** SET UP NEW PLOT LAYOUT LIMITS

ThisDrawing.ActiveSpace = acPaperSpace

Dim NewLowerX As Variant
Dim NewLowerY As Variant
Dim NewUpperX As Variant
Dim NewUpperY As Variant

Dim sysVarName As String
Dim xymin As Variant
Dim xymax As Variant

NewLowerX = 0#
NewLowerY = 0#
NewUpperX = 36#
NewUpperY = 24#

sysVarName = "LIMMIN"
   xymin = ThisDrawing.GetVariable(sysVarName)
sysVarName = "LIMMAX"
   xymax = ThisDrawing.GetVariable(sysVarName)

xymin(0) = NewLowerX: xymin(1) = NewLowerY
xymax(0) = NewUpperX: xymax(1) = NewUpperY

ThisDrawing.PaperSpace.Layout.SetWindowToPlot xymin, xymax

********************** CREATE NEW PLOT LAYOUT 

Dim D_PlotSize As String
D_PlotSize = "User2314" '<---------------- Use PlotPaperSizeNames.dvb to ascertain this value

Dim TempName As String
TempName = "SCI 24x36 (LANDSCAPE)"

Dim PlotLayoutConfig_24x36 As AcadLayout
Set PlotLayoutConfig_24x36 = ThisDrawing.ActiveLayout

Dim PlotConfigs_24x36 As AcadPlotConfigurations
Set PlotConfigs_24x36 = ThisDrawing.PlotConfigurations

Dim PlotConfig_24x36 As AcadPlotConfiguration
Set PlotConfig_24x36 = PlotConfigs_24x36.Add(TempName, True)

   With PlotConfig_24x36
       PlotLayoutConfig_24x36.RefreshPlotDeviceInfo
       PlotLayoutConfig_24x36.ShowPlotStyles = False
       PlotLayoutConfig_24x36.ConfigName = "MyPlotter"
       PlotLayoutConfig_24x36.StyleSheet = "MyCTB"
       PlotLayoutConfig_24x36.CanonicalMediaName = D_PlotSize
       PlotLayoutConfig_24x36.PlotType = acLayout
       'PlotLayoutConfig_24x36.CenterPlot = True
       PlotLayoutConfig_24x36.StandardScale = ac1_1
       PlotLayoutConfig_24x36.PaperUnits = acInches
       PlotLayoutConfig_24x36.PlotWithPlotStyles = True
       PlotLayoutConfig_24x36.PlotViewportsFirst = True
       PlotLayoutConfig_24x36.PlotRotation = ac0degrees
       PlotLayoutConfig_24x36.RefreshPlotDeviceInfo
   End With

ThisDrawing.Regen acAllViewports

************************** LOAD THE AVAILABLE "CanonicalMediaNames" 

End Sub


Private Sub GoGetCanonicalMediaNames()
Dim PaperSize As String
Dim MediaNames As Variant
Dim i As Integer
ThisDrawing.ActiveSpace = acPaperSpace
MediaNames = ThisDrawing.ActiveLayout.GetCanonicalMediaNames
For i = LBound(MediaNames) To UBound(MediaNames)
If StrComp(ThisDrawing.ActiveLayout.GetLocaleMediaName(MediaNames(i)), PaperSize, vbTextCompare) = 0 Then
ThisDrawing.ActiveLayout.CanonicalMediaName = MediaNames(i)
ThisDrawing.ActiveLayout.RefreshPlotDeviceInfo
End If
Next
End Sub
'*********************************************************************************************************************************
'*********************************************************************************************************************************

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...