巨大的坑,该代码来自于acadauto_2014--AutoCAD2014 ActiveX Reference Guide.chm 但是存在一个巨大的bug。
'获取所有的打印输出的图纸尺寸的名称 ,但是事前必须设置【打印机对象】也就是 Layouts("Model").ConfigName = "DWF Classic.pc3" 这样的代码,否则返回为空。
也就是说,先设置打印机,才能知道可打印图纸的尺寸。这个逻辑才是对的。这里是采用的vba ,其他的语音比如Python也是一样的
Sub Example_GetCanonicalMediaNames() '获取所有的打印输出的图纸尺寸的名称 ,但是事前必须设置【打印机对象】也就是 Layouts("Model").ConfigName = "DWF Classic.pc3" 这样的代码,否则返回为空 ' This example gets the current plot device information ' and then displays the list of plot device names, ' media names, localized media names, and plot style ' table entries. Dim Layout As ACADLayout Set Layout = ThisDrawing.ModelSpace.Layout ' Refresh the current plot information for ' this session. Layout.RefreshPlotDeviceInfo ' List all the valid device names for the system Dim plotDevices As Variant plotDevices = Layout.GetPlotDeviceNames() Dim x As Integer For x = LBound(plotDevices) To UBound(plotDevices) MsgBox plotDevices(x) Next ' List all the media names, and their localized version Dim mediaNames As Variant mediaNames = Layout.GetCanonicalMediaNames() For x = LBound(mediaNames) To UBound(mediaNames) MsgBox mediaNames(x) MsgBox Layout.GetLocaleMediaName(mediaNames(x)) Next ' List all the entries in the plot style table Dim styleNames As Variant styleNames = Layout.GetPlotStyleTableNames() For x = LBound(styleNames) To UBound(styleNames) MsgBox styleNames(x) Next End Sub
标签:GetCanonicalMediaNames,Dim,VBA,Layout,打印输出,mediaNames,plotDevices,styleNames,nam From: https://www.cnblogs.com/issacnew/p/18151656