What I have so far:
I do get an error on line:
Dim ReturnValue As New PlotSettings
Imports AAAS = Autodesk.AutoCAD.ApplicationServices
Imports AADS = Autodesk.AutoCAD.DatabaseServices
Imports AAG = Autodesk.AutoCAD.Geometry
Imports AAPS = Autodesk.AutoCAD.PlottingServices
Public Class PlotSettings
Public Sub New(ByVal plotsettings As AADS.PlotSettings)
Me.CfgName = plotsettings.PlotConfigurationName
Me.ModelType = plotsettings.ModelType
Me.OriginX = plotsettings.PlotOrigin.X
Me.OriginY = plotsettings.PlotOrigin.y
Me.PaperHeight = plotsettings.PlotPaperSize.Y '?
Me.PaperUnits = plotsettings.PlotPaperUnits
Me.PaperWidth = plotsettings.PlotPaperSize.X '?
Me.PaperXMax = plotsettings.PlotPaperMargins.MaxPoint.X
Me.PaperXMin = plotsettings.PlotPaperMargins.minpoint.X
Me.PaperYMax = plotsettings.PlotPaperMargins.MaxPoint.y
Me.PaperYMin = plotsettings.PlotPaperMargins.minpoint.y
Me.PapersizeDesc = plotsettings.CanonicalMediaName
Me.PlotCentered = plotsettings.PlotCentered
Me.PlotHidden = plotsettings.PlotHidden
Me.PlotPlotstyles = plotsettings.PlotPlotStyles
Me.PlotRotation = plotsettings.PlotRotation
Me.PlotType = plotsettings.PlotType
Me.PrintLineweights = plotsettings.PrintLineweights
Me.PrintScaleDenominator = plotsettings.CustomPrintScale.Denominator
Me.PrintScaleNumerator = plotsettings.CustomPrintScale.Numerator
Me.ScaleLineweights = plotsettings.ScaleLineweights
Me.ScaleType = plotsettings.StdScaleType
Me.ShowPlotstyles = plotsettings.ShowPlotStyles
Me.StandardScale = plotsettings.StdScale
Me.StyleSheet = plotsettings.CurrentStyleSheet
Me.UseStandardScale = plotsettings.UseStandardScale
Me.ViewportBorders = plotsettings.PlotViewportBorders
Me.ViewportsFirst = plotsettings.DrawViewportsFirst
Me.WindowXMax = plotsettings.PlotWindowArea.MaxPoint.X
Me.WindowXMin = plotsettings.PlotWindowArea.MinPoint.X
Me.WindowYMax = plotsettings.PlotWindowArea.MaxPoint.y
Me.WindowYMin = plotsettings.PlotWindowArea.MinPoint.y
End Sub
#Region " Properties "
Public Property CfgName As String
Public Property ModelType As Integer
Public Property OriginX As Double
Public Property OriginY As Double
Public Property PaperHeight As Double
Public Property PaperUnits As Integer
Public Property PaperWidth As Double
Public Property PaperXMax As Double
Public Property PaperXMin As Double
Public Property PaperYMax As Double
Public Property PaperYMin As Double
Public Property PapersizeDesc As String
Public Property PlotCentered As Integer
Public Property PlotHidden As Integer
Public Property PlotPlotstyles As Integer
Public Property PlotRotation As Integer
Public Property PlotType As Integer
Public Property PrintLineweights As Integer
Public Property PrintScaleDenominator As Double
Public Property PrintScaleNumerator As Double
Public Property ScaleLineweights As Integer
Public Property ScaleType As Integer
Public Property SettingName As String
Public Property ShowPlotstyles As Integer
Public Property StandardScale As Double
Public Property StyleSheet As String
Public Property UseStandardScale As Integer
Public Property ViewportBorders As Integer
Public Property ViewportsFirst As Integer
Public Property WindowXMax As Double
Public Property WindowXMin As Double
Public Property WindowYMax As Double
Public Property WindowYMin As Double
#End Region
#Region " Shared "
Public Function AcadEquivalent() As AADS.PlotSettings
Dim Validator As AADS.PlotSettingsValidator = AADS.PlotSettingsValidator.Current
Dim ReturnValue As AADS.PlotSettings = New AADS.PlotSettings(Me.ModelType)
Validator.SetPlotConfigurationName(ReturnValue, Me.CfgName, Me.PapersizeDesc)
Validator.SetPlotOrigin(ReturnValue, New AAG.Point2d(Me.OriginX, Me.OriginY))
Validator.SetPlotPaperUnits(ReturnValue, Me.PaperUnits)
Validator.SetPlotWindowArea(ReturnValue, New AADS.Extents2d(Me.WindowXMin, Me.WindowYMin, Me.WindowXMax, Me.windowYMax))
Validator.SetPlotType(returnvalue, Me.PlotType)
Validator.SetPlotCentered(ReturnValue, Me.PlotCentered)
ReturnValue.PlotHidden = Me.PlotHidden
Validator.SetPlotRotation(ReturnValue, Me.PlotRotation)
ReturnValue.PrintLineweights = Me.PrintLineweights
Validator.SetUseStandardScale(ReturnValue, Me.UseStandardScale)
If ReturnValue.UseStandardScale = True Then
'Validator.SetStdScale(ReturnValue, Me.StdScale)
Validator.SetStdScale(ReturnValue, Me.StandardScale)
'Validator.SetStdScaleType(ReturnValue, Me.StdScaleType)
Validator.SetStdScaleType(ReturnValue, Me.ScaleType)
Else
Validator.SetCustomPrintScale(ReturnValue, New AADS.CustomScale(Me.PrintScaleNumerator, Me.PrintScaleDenominator))
End If
ReturnValue.ScaleLineweights = Me.ScaleLineweights
ReturnValue.ShowPlotstyles = Me.ShowPlotstyles
Validator.SetCurrentStyleSheet(returnvalue, Me.StyleSheet)
ReturnValue.PlotViewportBorders = Me.ViewportBorders
ReturnValue.DrawViewportsFirst = Me.ViewportsFirst
Return returnvalue
End Function
Public Shared Function FromRegistry(ByVal ModelType As Boolean) As PlotSettings
Dim ReturnValue As New PlotSettings
'HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R18.1\ACAD-9002:409\Profiles\TRACKSTAR_GENERIC_MAP_2011\Previous plot settings
Dim ProdKeyStr As String
ProdKeyStr = Autodesk.AutoCAD.Runtime.SystemObjects.DynamicLinker.ProductKey
Dim PreviousPlotSettings As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(String.Format(ProdKeyStr & "\Profiles\{0}\Previous plot settings", AAAS.Application.GetSystemVariable("cprofile")), False)
'Dim PreviousPlotSettings As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(String.Format("Software\Autodesk\AutoCAD\R18.1\ACAD-9002:409\Profiles\{0}\Previous plot settings", AAAS.Application.GetSystemVariable("cprofile")), False)
If ModelType = True Then
PreviousPlotSettings = PreviousPlotSettings.opensubkey("Model")
Else
PreviousPlotSettings = PreviousPlotSettings.opensubkey("Layout")
End If
ReturnValue.CfgName = PreviousPlotSettings.GetValue("Cfg Name")
ReturnValue.ModelType = PreviousPlotSettings.GetValue("Model type")
ReturnValue.OriginX = CDbl(PreviousPlotSettings.GetValue("Origin X"))
ReturnValue.OriginY = CDbl(PreviousPlotSettings.GetValue("Origin Y"))
ReturnValue.PaperHeight = PreviousPlotSettings.GetValue("Paper height")
ReturnValue.PaperUnits = PreviousPlotSettings.GetValue("Paper units")
ReturnValue.PaperWidth = PreviousPlotSettings.GetValue("Paper width")
ReturnValue.PaperXMax = PreviousPlotSettings.GetValue("Paper XMax")
ReturnValue.PaperXMin = PreviousPlotSettings.GetValue("Paper XMin")
ReturnValue.PaperYMax = PreviousPlotSettings.GetValue("Paper YMax")
ReturnValue.PaperYMin = PreviousPlotSettings.GetValue("Paper YMin")
ReturnValue.PapersizeDesc = PreviousPlotSettings.GetValue("Papersize desc")
ReturnValue.PlotCentered = PreviousPlotSettings.GetValue("Plot centered")
ReturnValue.PlotHidden = PreviousPlotSettings.GetValue("Plot hidden")
ReturnValue.PlotPlotstyles = PreviousPlotSettings.GetValue("Plot plotstyles")
ReturnValue.PlotRotation = PreviousPlotSettings.GetValue("Plot rotation")
ReturnValue.PlotType = PreviousPlotSettings.GetValue("Plot type")
ReturnValue.PrintLineweights = PreviousPlotSettings.GetValue("Print lineweights")
ReturnValue.PrintScaleDenominator = CDbl(PreviousPlotSettings.GetValue("Print scale denominator"))
ReturnValue.PrintScaleNumerator = CDbl(PreviousPlotSettings.GetValue("Print scale numerator"))
ReturnValue.ScaleLineweights = PreviousPlotSettings.GetValue("Scale lineweights")
ReturnValue.ScaleType = PreviousPlotSettings.GetValue("Scale type")
ReturnValue.ShowPlotstyles = PreviousPlotSettings.GetValue("Show plotstyles")
ReturnValue.StandardScale = PreviousPlotSettings.GetValue("Standard scale")
ReturnValue.StyleSheet = PreviousPlotSettings.GetValue("Style sheet")
ReturnValue.UseStandardScale = PreviousPlotSettings.GetValue("Use standard scale")
ReturnValue.ViewportBorders = PreviousPlotSettings.GetValue("Viewport borders")
ReturnValue.ViewportsFirst = PreviousPlotSettings.GetValue("Viewports first")
ReturnValue.WindowXMax = PreviousPlotSettings.GetValue("Window XMax")
ReturnValue.WindowXMin = PreviousPlotSettings.GetValue("Window XMin")
ReturnValue.WindowYMax = PreviousPlotSettings.GetValue("Window YMax")
ReturnValue.WindowYMin = PreviousPlotSettings.GetValue("Window YMin")
Return returnvalue
End Function
#End Region
End Class
Where do I put this following code?
<CommandMethodAttribute("PPT")> _
Public Sub PreviousPlot
Dim pe As New PlottingServices.PlotEngine
pe.Plot(PlotSettings.FromRegistry(False).AcadEquivalent)
End Sub