- 积分
- 4760
- 明经币
- 个
- 注册时间
- 2002-11-30
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
Sub 添加打印设置()
Dim configname() As String = {"HP DesignJet 500 mono 24", "\\PRINT-SERVER\HP DesignJet 430 (E/A0) by HP", "HP LaserJet 5200 PCL 6"}
Dim CanonicalMediaName() As String = {"User621", "User1644", "User622", "User1645", "User1644", "A3", "A4"} 'A1,A2,,A0,A1,A2,,A3,A4
Dim plotname() As String = {"moA1", "moA2", "430A0", "430A1", "430A2", "LJA3", "LJA4"}
Dim plotconfigname As String = "cxb_plt.ctb"
Dim i As Integer
Dim acdoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acdoc.Database
''启动一个事务 Start a transaction
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
Dim acLayoutMgr As LayoutManager
acLayoutMgr = LayoutManager.Current
'' Get the current layout and output its name in the Command Line window
Dim acLayout As Layout
acLayout = acTrans.GetObject(acLayoutMgr.GetLayoutId(acLayoutMgr.CurrentLayout), _
OpenMode.ForRead)
Dim acPlSet As PlotSettings
'' Update the PlotConfigurationName property of the PlotSettings object
Dim acPlSetVdr As PlotSettingsValidator = PlotSettingsValidator.Current '这个东西与打印设置有什么关系?
For i = 0 To UBound(plotname)
acPlSet = New PlotSettings(acLayout.ModelType) '打印设置还能用什么办法添加?
acPlSet.PlotSettingsName = plotname(i)
Select Case i
Case 0, 1
acPlSetVdr.SetPlotConfigurationName(acPlSet, configname(0), CanonicalMediaName(i))
Case 2, 3, 4
acPlSetVdr.SetPlotConfigurationName(acPlSet, configname(1), CanonicalMediaName(i))
Case 5, 6
acPlSetVdr.SetPlotConfigurationName(acPlSet, configname(2), CanonicalMediaName(i))
End Select
acPlSetVdr.SetPlotCentered(acPlSet, True)
acPlSetVdr.SetCurrentStyleSheet(acPlSet, "cxb_plt.ctb")
acPlSetVdr.SetPlotPaperUnits(acPlSet, PlotPaperUnit.Millimeters)
If i = 6 Then
acPlSetVdr.SetPlotRotation(acPlSet, PlotRotation.Degrees000)
Else
acPlSetVdr.SetPlotRotation(acPlSet, PlotRotation.Degrees090)
End If
acPlSetVdr.SetPlotWindowArea(acPlSet, New Extents2d(0, 0, 5, 9))
acPlSetVdr.SetPlotType(acPlSet, Autodesk.AutoCAD.DatabaseServices.PlotType.Window)
acPlSetVdr.SetUseStandardScale(acPlSet, True)
acdoc.Editor.WriteMessage(vbLf & "New settings name: " & _
acPlSet.PlotSettingsName)
acdoc.Editor.WriteMessage(vbLf & "New device name: " & _
acPlSet.PlotConfigurationName)
'' 添加新对象到块表记录和事务中 Add the new object to the block table record and the transaction
'----------------------------------------------------------------------------------------------------------------------------
acPlSet.AddToPlotSettingsDictionary(acCurDb)
acTrans.AddNewlyCreatedDBObject(acPlSet, True)
'--------------------------------------------------------------------------------------------------------------------------------
Next
'如何设置默认的打印设置?
'如何删除某个打印设置?
acTrans.Commit()
'acTrans.Dispose()
End Using
End Sub
请高手梳理一下这一块的对象模型?
|
|