CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2018 开发者帮助

纸张大小和单位 (.NET)

2024-5-18 16:57| 发布者: admin| 查看: 9| 评论: 0|原作者: admin|来自: AutoCAD

纸张大小和单位 (.NET)

布局的纸张尺寸选择取决于为输出配置的绘图仪或设备。每个绘图仪或设备都有一个可用输出尺寸的标准列表,可以使用对象的方法获得这些输出尺寸。对象的方法可用于返回“打印”(Plot) 或“页面设置”(Page Setup) 对话框中显示的输出大小。可以使用该属性查询分配给布局的纸张大小。GetCanonicalMediaNameListPlotSettingsValidatorGetLocaleMediaNamePlotSettingsValidatorCanonicalMediaName

还可以使用该属性查询布局的单位。此属性返回枚举定义的三个值之一:、 或 。如果绘图仪配置为栅格输出,则输出大小以像素为单位返回。PlotPaperUnitsPlotPaperUnitInchesMillimetersPixels

列出输出设备的可用纸张尺寸

本示例列出了 DWF6 ePlot.pc3 输出设备的纸张尺寸。

VB.NET

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.PlottingServices

' Lists the available local media names for a specified plot configuration (PC3) file
<CommandMethod("PlotterLocalMediaNameList")> _
Public Shared Sub PlotterLocalMediaNameList()
    ' Get the current document and database, and start a transaction
    Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument

    Using plSet As PlotSettings = New PlotSettings(True)
        Dim acPlSetVdr As PlotSettingsValidator = PlotSettingsValidator.Current

        ' Set the Plotter and page size
        acPlSetVdr.SetPlotConfigurationName(plSet, "DWF6 ePlot.pc3", _
                                            "ANSI_A_(8.50_x_11.00_Inches)")

        acDoc.Editor.WriteMessage(vbLf & "Canonical and Local media names: ")

        Dim cnt As Integer = 0

        For Each mediaName As String In acPlSetVdr.GetCanonicalMediaNameList(plSet)

            ' Output the names of the available media for the specified device
            acDoc.Editor.WriteMessage(vbLf & "  " & mediaName & " | " & _
                                      acPlSetVdr.GetLocaleMediaName(plSet, cnt))

            cnt = cnt + 1
        Next
    End Using
End Sub

C#

using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.PlottingServices;

// Lists the available local media names for a specified plot configuration (PC3) file
[CommandMethod("PlotterLocalMediaNameList")]
public static void PlotterLocalMediaNameList()
{
    // Get the current document and database, and start a transaction
    Document acDoc = Application.DocumentManager.MdiActiveDocument;

    using(PlotSettings plSet = new PlotSettings(true))
    {
        PlotSettingsValidator acPlSetVdr = PlotSettingsValidator.Current;

        // Set the Plotter and page size
        acPlSetVdr.SetPlotConfigurationName(plSet, "DWF6 ePlot.pc3",
                                            "ANSI_A_(8.50_x_11.00_Inches)");

        acDoc.Editor.WriteMessage("\nCanonical and Local media names: ");

        int cnt = 0;

        foreach (string mediaName in acPlSetVdr.GetCanonicalMediaNameList(plSet))
        {
            // Output the names of the available media for the specified device
            acDoc.Editor.WriteMessage("\n  " + mediaName + " | " +
                                      acPlSetVdr.GetLocaleMediaName(plSet, cnt));

            cnt = cnt + 1;
        }
    }
}

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-6-27 15:47

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部