My new PageSetup doesn't show in the Pagesetup dialog.
Please help.... I don't know where I'm going wrong.
I can find it using:
But the code in the second section doesn't work properly.
<CommandMethod("its")> _
Public Sub IteratePage()
'' Get the current document and database, and start a transaction
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
'' This example returns the PageSetup table for the current database
Dim acPltDic As DBDictionary
Dim acPltDicEntry As DBDictionaryEntry
Dim acPageSetup As PlotSettings
Dim PL1 As PlotSettings = New PlotSettings(True)
PL1.PlotSettingsName = "X"
acPltDic = acTrans.GetObject(acCurDb.PlotSettingsDictionaryId, _
OpenMode.ForRead)
'' Step through the PageSetup table and print each PageSetup name
Dim objId As ObjectId
For Each acPltDicEntry In acPltDic
MsgBox("Key: " & acPltDicEntry.Key)
'Get PageSetup
objId = acPltDic.GetAt(acPltDicEntry.Key)
acPageSetup = objId.GetObject(OpenMode.ForRead)
MsgBox("Pagesetup: " & acPageSetup.PlotSettingsName)
Next
'' Dispose of the transaction
End Using
End Sub
<CommandMethod("aps")> _
Public Sub AddPlotSetting_DOTNET()
'TODO: Finish Cleaning Print Function
Dim s_PlotSettingsFile As String = "C:\TEST.dwg"
Dim s_PageSetupName As String = "catdog"
Dim s_MediaName As String = "11 x 17"
Dim s_PlotDeviceName As String = "\\rdops1\RDO0071"
Dim s_StyleSheetName As String = "Monochrome.ctb"
Dim d_PaperHeight As Double = 11
Dim d_PaperWidth As Double = 17
Dim is_PlotStyles As Boolean = True
Dim int_PlotRotation As PlotRotation = PlotRotation.Degrees000
Dim int_PlotType As Autodesk.AutoCAD.DatabaseServices.PlotType = Autodesk.AutoCAD.DatabaseServices.PlotType.Extents
Dim int_StandardScale As Integer = StdScaleType.ScaleToFit
Dim is_PlotCentered As Boolean = True
Dim myPoint As New Autodesk.AutoCAD.Geometry.Point2d(0, 0)
Dim CurrentDatabase As Database = Application.DocumentManager.MdiActiveDocument.Database
Using currentTransaction As Transaction = CurrentDatabase.TransactionManager.StartTransaction
'' Reference the Layout Manager
Dim acLayoutMgr As LayoutManager
acLayoutMgr = LayoutManager.Current
ed.WriteMessage("Current Layout: " & acLayoutMgr.CurrentLayout)
'' Get the current layout
Dim acLayout As Layout
acLayout = currentTransaction.GetObject(acLayoutMgr.GetLayoutId(acLayoutMgr.CurrentLayout), _
OpenMode.ForRead)
'TODO: Confirm New Print Object is Created
'Create PlotSetting
Dim pl As PlotSettings = New PlotSettings(acLayout.ModelType)
pl.CopyFrom(acLayout)
Dim plinfo As PlotInfo = New PlotInfo
plinfo.Layout = acLayout.ObjectId
'Create PlotSettingsValidator
Dim psv As PlotSettingsValidator = PlotSettingsValidator.Current
psv.RefreshLists(pl)
'Set Plot Type
psv.SetPlotType(pl, Autodesk.AutoCAD.DatabaseServices.PlotType.Extents)
'set plot scale
psv.SetUseStandardScale(pl, True)
psv.SetStdScaleType(pl, StdScaleType.ScaleToFit)
'Center the plot
psv.SetPlotCentered(pl, True)
'Rotation
psv.SetPlotRotation(pl, PlotRotation.Degrees000)
psv.SetPlotOrigin(pl, myPoint)
'Set Media Size
psv.SetCanonicalMediaName(pl, "Letter")
'TODO: Validate StyleSheetName
psv.SetCurrentStyleSheet(pl, s_StyleSheetName)
'' Set the plot device to use
psv.SetPlotConfigurationName(pl, s_PlotDeviceName, "Letter")
'Make Default PageSetup Yes/No?
'psv.SetDefaultPlotConfig(pl)
'Set the PageSetup Name
pl.PlotSettingsName = s_PageSetupName
pl.PlotHidden = False
MsgBox("Resident: " & pl.IsTransactionResident)
'Add to Plot Settings to Drawing Database
pl.AddToPlotSettingsDictionary(CurrentDatabase)
currentTransaction.Commit()
End Using
End Sub