I am trying to change the Canonical Media Name type in my VBA code, but I keep getting overridden with other values (for reason I don't know why) I also tried passing variables through another sub, but this isn't working either. I was wondering if someone has an idea floating around to by pass this. I have tried using
myLayout.Regen acAllViewports
to update my viewports and
myLayout.RefreshPlotDeviceInfo
to also update my code.
I am currently restructuring this code provided by norman.yuan from https://forums.autodesk.com/t5/visual-basic-customization/trying-to-rotate-a-plotted-drawing/m-p/910... which can be seen below:
Option Explicit
Public Sub PlotTest()
Dim backPlot As Integer
Dim PaperSize As String
backPlot = ThisDrawing.GetVariable("BACKGROUNDPLOT")
ThisDrawing.SetVariable "BACKGROUNDPLOT", 0
On Error Resume Next
PaperSize = "11x17"
PlotToPdf ThisDrawing, "D:\Temp\TestDwgPlot1.pdf", ac0degrees
PlotToPdf ThisDrawing, "D:\Temp\TestDwgPlot2.pdf", ac90degrees
ThisDrawing.SetVariable "BACKGROUNDPLOT", backPlot
End Sub
Private Sub PlotToPdf(currentDwg As AcadDocument, pdfFile As String, plotRotation As AcPlotRotation, Papersize As String)
Dim myLayout As ACADLayout
Dim currentPlot As AcadPlot
Set myLayout = currentDwg.ModelSpace.Layout
myLayout.StyleSheet = "monochrome.ctb"
myLayout.plotRotation = plotRotation
myLayout.ConfigName = "DWG To PDF.pc3"
myLayout.CanonicalMediaName = PaperSize
myLayout.StandardScale = acScaleToFit
myLayout.PlotType = acExtents
myLayout.CenterPlot = True
Set currentPlot = currentDwg.Plot
currentPlot.DisplayPlotPreview acFullPreview
If currentPlot.PlotToFile(pdfFile) Then
MsgBox pdfFile & " generated successfully."
End If
End Sub