乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 14|回复: 0

关于打印设置

[复制链接]

15

主题

34

帖子

6

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
94
发表于 2012-3-2 14:30:00 | 显示全部楼层 |阅读模式
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..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
请高手梳理一下这一块的对象模型?
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-15 21:18 , Processed in 0.337524 second(s), 54 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表