I am not an expert. That can be verified by some of my dim-witted postings heron.
I have been working on a project that uses the .Net interface to create postscript files using AutoCAD Mechanical 2006.
Here is some code that may help. I am sure that you this may help you get a listing of the available PlotSettings (aka PlotConfigurations through the COM interface)
You should be able to past this function into the "HelloWorld" sample.
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
_
Public Function HelloTextCommand()
Dim oAcadDB As Database = Application.DocumentManager.MdiActiveDocument.Database
Dim oAcadEditor As Editor = Application.DocumentManager.MdiActiveDocument.Editor
'Get Value of the "BackGroundPlot" system Variable
Dim oAcadCOMApp As Autodesk.AutoCAD.Interop.AcadApplication = CType(AcadCOMintf.AcadApplication, AcadApplication)
Dim ExistingBGPVal As Short = oAcadCOMApp.ActiveDocument.GetVariable("BACKGROUNDPLOT")
Dim NewBGPVal As Short = 0
oAcadCOMApp.ActiveDocument.SetVariable("BACKGROUNDPLOT", NewBGPVal)
oAcadCOMApp = Nothing
oAcadCOMApp = CType(AcadCOMintf.AcadApplication, AcadApplication)
'Find BlockReference for Format "d1+format" on Layout - Layout2
Dim oTypedValues() As TypedValue = { _
New TypedValue(DxfCode.Start, "INSERT"), _
New TypedValue(DxfCode.BlockName, UCase("d1+format")) _
}
Dim oAcadSelectionFilter As New SelectionFilter(oTypedValues) ' Create the filter using our values...
Dim oAcadSelectionResult As PromptSelectionResult = oAcadEditor.SelectAll(oAcadSelectionFilter)
Dim oAcadSelectionSet As Autodesk.AutoCAD.EditorInput.SelectionSet = oAcadSelectionResult.Value
If oAcadSelectionSet Is Nothing Then
MsgBox("No TestFormat Found")
Exit Function
End If
Dim oAcadIDArray As ObjectId() = oAcadSelectionSet.GetObjectIds()
Dim oAcadTransactionManager As Autodesk.AutoCAD.DatabaseServices.TransactionManager = oAcadDB.TransactionManager
Dim StartTime As Date = Now
Dim oAcadTransaction As Transaction = oAcadTransactionManager.StartTransaction()
Try
Dim oObjectID As ObjectId
Dim oBlockRef As BlockReference
Dim oObject As DBObject
For Each oObjectID In oAcadIDArray
oObject = oAcadTransactionManager.GetObject(oObjectID, OpenMode.ForRead)
If TypeOf oObject Is BlockReference Then ' get layout
oBlockRef = CType(oObject, BlockReference)
Dim oBlockOwnerRefObjectID As ObjectId = oBlockRef.OwnerId
Dim oOwnerBlockTableRecord As BlockTableRecord = CType(oAcadTransaction.GetObject(oBlockOwnerRefObjectID, OpenMode.ForWrite, False, False), BlockTableRecord)
Dim olayoutObjectID As ObjectId = oOwnerBlockTableRecord.LayoutId
Dim oLayoutID As ObjectId = oOwnerBlockTableRecord.LayoutId
Dim olayout As Layout = CType(oAcadTransaction.GetObject(oLayoutID, OpenMode.ForWrite, False, False), Layout)
Dim oLayoutManager As Autodesk.AutoCAD.DatabaseServices.LayoutManager = Autodesk.AutoCAD.DatabaseServices.LayoutManager.Current
oLayoutManager.CurrentLayout = olayout.LayoutName ' sets Layout1 active
Dim oAcadViewTable As Autodesk.AutoCAD.DatabaseServices.ViewTable
oAcadViewTable = CType(oAcadTransaction.GetObject(oAcadDB.ViewTableId, OpenMode.ForWrite, False, False), ViewTable)
Dim oAcadViewTableRecord As Autodesk.AutoCAD.DatabaseServices.ViewTableRecord
Dim oAcadViewTableRecordID As Autodesk.AutoCAD.DatabaseServices.ObjectId
Dim strName As String = "TestView"
Dim blnViewExist As Boolean = False
For Each oAcadViewTableRecordID In oAcadViewTable ' search for a view with the same name in the table
oAcadViewTableRecord = CType(oAcadTransaction.GetObject(oAcadViewTableRecordID, OpenMode.ForWrite, False, False), Autodesk.AutoCAD.DatabaseServices.ViewTableRecord)
If oAcadViewTableRecord.Name = strName Then
blnViewExist = True
Exit For
End If
Next
If Not blnViewExist Then 'if not, make a new view table (oAcadViewTable is open via a ForWrite transaction above)
oAcadViewTableRecord = New Autodesk.AutoCAD.DatabaseServices.ViewTableRecord
oAcadViewTableRecord.Name = strName
oAcadViewTable.Add(oAcadViewTableRecord)
oAcadViewTableRecordID = oAcadViewTableRecord.ObjectId
oAcadTransactionManager.AddNewlyCreatedDBObject(oAcadViewTableRecord, True)
End If
For Each oAcadViewTableRecordID In oAcadViewTable ' open ViewTable for Write
oAcadViewTableRecord = CType(oAcadTransaction.GetObject(oAcadViewTableRecordID, OpenMode.ForWrite, False, False), Autodesk.AutoCAD.DatabaseServices.ViewTableRecord)
If oAcadViewTableRecord.Name = strName Then
blnViewExist = True
Exit For
End If
Next
oAcadViewTableRecord.Layout = olayout.ObjectId
oAcadViewTableRecord.Width = 34.0
oAcadViewTableRecord.Height = 22.0
Dim strCenterPoint As New Autodesk.AutoCAD.Geometry.Point2d(oBlockRef.Position.X + 17.0, oBlockRef.Position.Y + 11.0)
oAcadViewTableRecord.CenterPoint = strCenterPoint
oAcadViewTableRecord.ViewTwist = 0.0
oAcadViewTableRecord.CategoryName = "Test Viewport Category"
Dim oAcadPSDictID As ObjectId = oAcadDB.PlotSettingsDictionaryId
Dim oAcadPSdict As DBDictionary
Dim oPSVal As PlotSettingsValidator = PlotSettingsValidator.Current
oAcadPSdict = CType(oAcadTransaction.GetObject(oAcadPSDictID, OpenMode.ForWrite, False, False), DBDictionary)
Dim oDictEntry As DictionaryEntry
Dim PSExist As Boolean
Dim PSObjectID As ObjectId
Dim PSisLayout As Boolean
Dim strPSName As String = "TestPlotSetting"
For Each oDictEntry In oAcadPSdict
If oDictEntry.Key = strPSName Then
PSExist = True
PSObjectID = oDictEntry.Value
Exit For
End If
Next
Dim oPlotSettings As PlotSettings
If PSExist Then
oPlotSettings = CType(oAcadTransaction.GetObject(PSObjectID, OpenMode.ForWrite, False, False), PlotSettings)
Else
oPlotSettings = New PlotSettings(False) ' False Paperspace, True ModelSpace
oPlotSettings.PlotSettingsName = strPSName
oPlotSettings.AddToPlotSettingsDictionary(oAcadDB)
oAcadTransactionManager.AddNewlyCreatedDBObject(oPlotSettings, True)
For Each oDictEntry In oAcadPSdict ' Adding the PlotSetting to the dictionary modifies the Object ID.
' This operation resets the PlotSetting object
If oDictEntry.Key = strPSName Then
PSObjectID = oDictEntry.Value
Exit For
End If
Next
oPlotSettings = CType(oAcadTransaction.GetObject(PSObjectID, OpenMode.ForWrite, False, False), PlotSettings)
End If
With oPSVal
.RefreshLists(oPlotSettings)
.SetPlotConfigurationName(oPlotSettings, "AutoCAD PostScript File Writer.pc3", "UserDefinedImperial (34.00 x 22.00Inches)")
.SetDefaultPlotConfig(oPlotSettings)
.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)
.SetPlotType(oPlotSettings, Autodesk.AutoCAD.DatabaseServices.PlotType.Window)
Dim oCusScale As New Autodesk.AutoCAD.DatabaseServices.CustomScale(1.0, 1.0)
.SetCustomPrintScale(oPlotSettings, oCusScale)
.SetPlotCentered(oPlotSettings, True)
.SetZoomToPaperOnUpdate(oPlotSettings, True)
.SetCanonicalMediaName(oPlotSettings, "UserDefinedImperial (34.00 x 22.00Inches)")
.SetCurrentStyleSheet(oPlotSettings, "monochrome.ctb")
End With
Dim oPlotInfo As New Autodesk.AutoCAD.PlottingServices.PlotInfo
Dim oPageInfo As New Autodesk.AutoCAD.PlottingServices.PlotPageInfo
Dim oPPD As New Autodesk.AutoCAD.PlottingServices.PlotProgressDialog(False, 1, False)
Dim oPlotEngine As Autodesk.AutoCAD.PlottingServices.PlotEngine = Autodesk.AutoCAD.PlottingServices.PlotFactory.CreatePublishEngine
oPlotInfo.Layout = olayout.ObjectId
oPlotInfo.ValidatedSettings = oPlotSettings
oPlotInfo.OverrideSettings = oPlotSettings
Dim oPIValidator As Autodesk.AutoCAD.PlottingServices.PlotInfoValidator = New Autodesk.AutoCAD.PlottingServices.PlotInfoValidator
oPIValidator.MediaMatchingPolicy = Autodesk.AutoCAD.PlottingServices.MatchingPolicy.MatchEnabled
oPIValidator.Validate(oPlotInfo)
System.Windows.Forms.Application.DoEvents()
With oPPD
.PlotMsgString(PlotMessageIndex.DialogTitle) = "Creating PostScript Files required for PDF Creation"
.PlotMsgString(PlotMessageIndex.SheetName) = " Test Sheet Name : "
.PlotMsgString(PlotMessageIndex.SheetName) = " Sheet Name Text"
.PlotMsgString(PlotMessageIndex.Status) = " Status name Text "
.LowerPlotProgressRange = 0
.UpperPlotProgressRange = 100
.IsVisible = True
.OnBeginPlot()
End With
With oPlotEngine
.BeginPlot(oPPD, Nothing)
.BeginDocument(oPlotInfo, "Test Document Name.dwg", Nothing, CInt(1), True, "C:\temp\Test.ps")
.BeginPage(oPageInfo, oPlotInfo, True, Nothing)
.BeginGenerateGraphics(Nothing)
.EndGenerateGraphics(Nothing)
.EndPage(Nothing)
oPPD.PlotProgressPos = 100
.EndDocument(Nothing)
.EndPlot(Nothing)
oPPD.IsVisible = False
End With
Dim EndTime As Date = Now
Dim Ts As System.TimeSpan = EndTime.Subtract(StartTime)
Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(vbNewLine + "Total Elapsed Time (seconds,milliseconds) : " & Ts.Seconds & " : " & Ts.Milliseconds & " .... ")
If Not oPPD Is Nothing Then
oPPD.IsVisible = False
oPPD.Destroy()
oPPD.Dispose()
oPPD = Nothing
End If
If Not oPageInfo Is Nothing Then
oPageInfo.Dispose()
oPageInfo = Nothing
End If
If Not oPlotInfo Is Nothing Then
oPlotInfo.Dispose()
oPlotInfo = Nothing
End If
If Not oPIValidator Is Nothing Then
oPIValidator.Dispose()
oPIValidator = Nothing
End If
If Not oPlotEngine Is Nothing Then
oPlotEngine.Destroy()
oPlotEngine.Dispose()
oPlotEngine = Nothing
End If
If Not oPlotSettings Is Nothing Then
oPlotSettings.Dispose()
oPlotSettings = Nothing
End If
If Not oPSVal Is Nothing Then
oPSVal.Dispose()
oPSVal = Nothing
End If
End If
Next
oAcadTransaction.Commit()
oAcadTransaction.Dispose()
oAcadTransaction = Nothing
oAcadTransactionManager.Dispose()
oAcadTransactionManager = Nothing
oAcadSelectionFilter = Nothing
oAcadSelectionSet = Nothing
oTypedValues = Nothing
oAcadIDArray = Nothing
oAcadEditor = Nothing
oAcadDB = Nothing
Catch ex As Exception
End Try
End Function
::::::::::::::::::::::::::::::::::::::::
I think that you may be interested in the PlotSettings dictionary portion of the above code