yyrr1984 发表于 2007-6-6 19:54:00

[求助]打印的程序为什么出错?帮忙指正下!!

<p>我自己边的一个打印程序,其中有三处错误,请高手指点一下为什么错了,我找了半天都没找出来,小弟初学</p><p>Public Sub PLprint()<br/>ThisDrawing.ActiveLayout = ThisDrawing.Layouts.Item("Model")<br/>ThisDrawing.ActiveLayout.ConfigName = "DWF6 ePlot.pc3"</p><p>'设置打印方式是窗口</p><p>&nbsp;&nbsp;&nbsp; ThisDrawing.ModelSpace.Layout.PlotType = acWindow</p><p></p><p>Dim ptMin As Variant, ptMax As Variant<br/>Dim ent As AcadEntity</p><p><font color="#ff0000">ThisDrawing.SetVariable "BACKGROUNDPLOT", 0<br/>'这里显示设置系统变量时出错</font></p><p>&nbsp;&nbsp;&nbsp; For Each ent In ThisDrawing.ModelSpace<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If TypeOf ent Is AcadBlockReference Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If StrComp(ent.Name, "actj2tk", vbTextCompare) = 0 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ent.GetBoundingBox ptMin, ptMax<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp; Next ent<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' 设置打印范围<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ReDim Preserve ptMin(0 To 1)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ReDim Preserve ptMax(0 To 1)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ThisDrawing.ModelSpace.Layout.SetWindowToPlot ptMin, ptMax</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </p><p></p><p>'设置打印比例为缩放到图纸大小,并中心对正<br/>&nbsp;&nbsp;&nbsp; ThisDrawing.ModelSpace.Layout.StandardScale = acScaleToFit<br/>&nbsp;&nbsp;&nbsp; ThisDrawing.ModelSpace.Layout.CenterPlot = True<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '设置笔为彩色<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp; <font color="#ff0000">ThisDrawing.ActiveLayout.StyleSheet = "DWF Virtual Pens.ctb"<br/>&nbsp;&nbsp; '这里显示输入有无效,可我看了cad中打印样式就这样的呀!</font><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; '选择打印机和纸张<br/>&nbsp;&nbsp;&nbsp; ThisDrawing.ModelSpace.Layout.ConfigName = "WINDOW.PC3"<br/><font color="#ff0000">&nbsp;&nbsp;&nbsp; ThisDrawing.ModelSpace.Layout.CanonicalMediaName = "600*2000 毫米"<br/>&nbsp;&nbsp;&nbsp; '这里提示输入无效,我自己设的纸张大小是600*2000的,要是有错该写成什么样呢?</font><br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ' 设置打印份数为1<br/>&nbsp;&nbsp;&nbsp; ThisDrawing.Plot.NumberOfCopies = 1<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ' 设置安静打印</p><p>&nbsp;&nbsp;&nbsp; ThisDrawing.Plot.QuietErrorMode = True<br/>&nbsp;&nbsp;&nbsp; </p><p><br/>'打印<br/>&nbsp;&nbsp;&nbsp; ThisDrawing.Plot.PlotToDevice<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ThisDrawing.SetVariable "BACKGROUNDPLOT", 2<br/>End Sub<br/></p>

yyrr1984 发表于 2007-6-13 19:57:00

[讨论]为什么没有人回答呀?我等着用

为什么没有人回答呀?我等着用

fjfhgdwfn 发表于 2007-6-14 09:02:00

<p>应是没有样式表和不支持你的图纸。</p>

fjfhgdwfn 发表于 2007-6-14 09:02:00

<p>应是没有样式表和不支持你的图纸。</p>

qazllqaz 发表于 2009-2-13 18:58:00

<p><br/>&nbsp;&nbsp;&nbsp; ThisDrawing.ActiveLayout = ThisDrawing.Layouts.Item("Model")<br/>&nbsp;<br/>&nbsp;&nbsp;&nbsp; ThisDrawing.ActiveLayout.PlotType = acWindow<br/><br/>&nbsp;&nbsp;&nbsp; ThisDrawing.SetVariable "BACKGROUNDPLOT", 0</p><p></p><p>我用这句是对的</p>

jfcui 发表于 2009-6-24 17:27:00

我输入样式的时候也出现这样的问题,不知道是什么原因,急死人了。提示输入无效。
页: [1]
查看完整版本: [求助]打印的程序为什么出错?帮忙指正下!!