Posts: 11
Registered: ‎01-05-2007
Message 1 of 3 (480 Views)

"Set Current" PlotSettings/Page Setup

480 Views, 2 Replies
01-10-2007 02:10 PM
Well, I've been following posts on related subjects since I am new to this. Found many postings helpful as you can see below. However, When I try to Create a pagesetup and set it current I am unable to set the newly created Page Setup as current. When I examine the item it works fine, I am able to set it current. If anyone is familiar with this and can provide input I would be extremely greatful.

Public Sub SetPlotSettings()
Dim Doc As Document = Application.DocumentManager.MdiActiveDocument
Dim DocLock As DocumentLock = Doc.LockDocument
Dim oAcadDB As Autodesk.AutoCAD.DatabaseServices.Database = Application.DocumentManager.MdiActiveDocument.Database
Dim oAcadTransactionManager As Autodesk.AutoCAD.DatabaseServices.TransactionManager = oAcadDB.TransactionManager
Dim oAcadTransaction As Transaction = oAcadTransactionManager.StartTransaction()
Dim oPlotSettingsObjectID As ObjectId = oAcadDB.PlotSettingsDictionaryId
Dim oPlotSettingsDBDictionary As Autodesk.AutoCAD.DatabaseServices.DBDictionary = CType(oAcadTransaction.GetObject(oPlotSettingsObjectID, OpenMode.ForWrite, False, False), DBDictionary)
Dim oDictionaryEntry As DictionaryEntry
Dim BoolPlotSettingsExist As Boolean
Dim StrPlotSettings As String = "TEST Pagesetup"
Dim oPlotSettings As New Autodesk.AutoCAD.DatabaseServices.PlotSettings(False)
Dim oPlotSettingsValidator As Autodesk.AutoCAD.DatabaseServices.PlotSettingsValidator = Autodesk.AutoCAD.DatabaseServices.PlotSettingsValidator.Current
Dim oPlotConfig As Autodesk.AutoCAD.PlottingServices.PlotConfig = Autodesk.AutoCAD.PlottingServices.PlotConfigManager.CurrentConfig
Dim oPlotInfo As Autodesk.AutoCAD.PlottingServices.PlotInfo = New Autodesk.AutoCAD.PlottingServices.PlotInfo()
Dim oLayoutManager As Autodesk.AutoCAD.DatabaseServices.LayoutManager = Autodesk.AutoCAD.DatabaseServices.LayoutManager.Current
Dim oLayout As Autodesk.AutoCAD.DatabaseServices.Layout = oLayoutManager.GetLayoutId(oLayoutManager.CurrentLayout).GetObject(OpenMode.ForRead, False, False)
For Each oDictionaryEntry In oPlotSettingsDBDictionary
If oDictionaryEntry.Key = StrPlotSettings Then
BoolPlotSettingsExist = True
oPlotSettingsObjectID = oDictionaryEntry.Value
Exit For
End If
If BoolPlotSettingsExist = True Then
oPlotSettings = CType(oAcadTransaction.GetObject(oPlotSettingsObjectID, OpenMode.ForWrite, False, False), PlotSettings)
oPlotSettings = New PlotSettings(False) ' False Paperspace, True ModelSpace
oPlotSettings.PlotSettingsName = StrPlotSettings
oPlotSettings.DrawViewportsFirst = False
oPlotSettings.PlotHidden = False
oPlotSettings.PlotPlotStyles = True
oPlotSettings.PlotViewportBorders = False
oPlotSettings.PrintLineweights = True
oPlotSettings.ScaleLineweights = True
oPlotSettings.ShadePlot = PlotSettingsShadePlotType.AsDisplayed
oPlotSettings.ShowPlotStyles = True
oAcadTransactionManager.AddNewlyCreatedDBObject(oPlotSettings, True)
For Each oDictionaryEntry In oPlotSettingsDBDictionary ' Adding the PlotSetting to the dictionary modifies the Object ID.
' This operation resets the PlotSetting object
If oDictionaryEntry.Key = StrPlotSettings Then
oPlotSettingsObjectID = oDictionaryEntry.Value
Exit For
End If
oPlotSettings = CType(oAcadTransaction.GetObject(oPlotSettingsObjectID, OpenMode.ForWrite, False, False), PlotSettings)

End If
With oPlotSettingsValidator
.SetPlotConfigurationName(oPlotSettings, Autodesk.AutoCAD.PlottingServices.PlotConfigManager.Devices(10).DeviceName, oPlotConfig.CanonicalMediaNames(10).ToString)
'.SetClosestMediaName(oPlotSettings, 8, 11, PlotPaperUnit.Inches, True)
.SetStdScale(oPlotSettings, 1)
.SetUseStandardScale(oPlotSettings, True)
.SetStdScaleType(oPlotSettings, StdScaleType.StdScale1To1)
.SetPlotRotation(oPlotSettings, PlotRotation.Degrees000)
.SetPlotPaperUnits(oPlotSettings, PlotPaperUnit.Inches)
'Dim oWindow As New Autodesk.AutoCAD.DatabaseServices.Extents2d(oBlockRef.Position.X, oBlockRef.Position.Y,oBlockRef.Position.X + 34.0, oBlockRef.Position.Y + 22.0)
'.SetPlotWindowArea(oPlotSettings, oWindow)
'.SetPlotOrigin(oPlotSettings, New Autodesk.AutoCAD.Geometry.Point2d(0, 0))
.SetPlotType(oPlotSettings, Autodesk.AutoCAD.DatabaseServices.PlotType.Extents)
Dim oCusScale As New Autodesk.AutoCAD.DatabaseServices.CustomScale(1.0, 1.0)
.SetCustomPrintScale(oPlotSettings, oCusScale)
.SetPlotCentered(oPlotSettings, True)
.SetZoomToPaperOnUpdate(oPlotSettings, True)
'.SetCanonicalMediaName(oPlotSettings, oPlotConfig.CanonicalMediaNames(10).ToString)
.SetCurrentStyleSheet(oPlotSettings, "ACCO_Std_1-4.ctb")
oCusScale = Nothing
End With
oAcadDB = Nothing
oAcadTransactionManager = Nothing
oAcadTransaction = Nothing
oPlotSettingsObjectID = Nothing
oPlotSettingsDBDictionary = Nothing
oDictionaryEntry = Nothing
StrPlotSettings = Nothing
oPlotSettings = Nothing
oPlotSettingsValidator = Nothing
oPlotConfig = Nothing
oPlotInfo = Nothing
'Doc = Nothing
Catch ex As Exception
End Try
End Sub
Posts: 4
Registered: ‎10-08-2007
Message 2 of 3 (480 Views)

Re: "Set Current" PlotSettings/Page Setup

10-08-2007 07:03 AM in reply to: Human.Man.Name=Jose
I've got the same Problem. I'm trying to set the new Page Setup as the used Pagesetup of the current Layout. But don't know how.

Has anybody an idea?

Posts: 17
Registered: ‎01-27-2005
Message 3 of 3 (480 Views)

Re: "Set Current" PlotSettings/Page Setup

11-27-2007 02:15 PM in reply to: Human.Man.Name=Jose
Have you tried using the copyfrom method for the current layout? That is, lo.copyfrom (ps) where ps is the plotsettings you just created.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.