mayuezxl 发表于 2006-1-14 20:44:00

[求助]如何打印所有图层

我用VB在CAD里生成了1000多个图层,其中三个图层的内容是公共图层,打印时要和其它图层一起打印。我现在只能先关闭不打印的图层,然后再打印,这样需重复1000多次。谢谢各位帮帮我,怎样用程序实现自动打印?我跪求了!

68651521 发表于 2006-1-14 21:44:00

<P>没看懂</P>
<P>假设A、B、C三个图层是公共图层 </P>
<P>其他的1000多个图层 每个图层要打一份 ?</P>
<P>就是 A+B+C的内容 加上第1个图层的内容 = 打印一份</P>
<P>就是 A+B+C的内容 加上第2个图层的内容 = 打印一份</P>
<P>就是 A+B+C的内容 加上第3个图层的内容 = 打印一份</P>
<P>…………</P>
<P>…………</P>
<P>???是这样么?</P>

mayuezxl 发表于 2006-1-14 21:54:00

谢谢楼上的,我就是这个意思,可是怎么才能做到用程序打印呢?谢谢了!

68651521 发表于 2006-1-14 22:16:00

<P>Sub Test()<BR>Dim a As AcadLayer</P>
<P>&nbsp;</P>
<P>For i = 0 To ThisDrawing.Layers.Count - 1<BR>&nbsp;&nbsp;&nbsp; ThisDrawing.Layers.Item(i).LayerOn = False<BR>Next i</P>
<P>ThisDrawing.Layers("公共图层1").LayerOn = True '改成具体的名字<BR>ThisDrawing.Layers("公共图层2").LayerOn = True '改成具体的名字<BR>ThisDrawing.Layers("公共图层3").LayerOn = True '改成具体的名字</P>
<P>For Each a In ThisDrawing.Layers<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; If a.LayerOn = False Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a.LayerOn = True<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; '是不是把图层关了 就不会打印了?<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; <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; a.LayerOn = False<BR>&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </P>
<P>Next a</P>
<P>End Sub<BR></P>
<P>&nbsp;</P>
<P>应该能行</P>

68651521 发表于 2006-1-14 22:22:00

<P>还有 再那2行=====之间加代码的时候 最好加一句 </P>
<P>MsgBox "现在正在打印的图层是" + a.Name + ",先不要按确定,等打完了再按."</P>

68651521 发表于 2006-1-14 22:35:00

<P>帮你写好了</P>
<P>先设置好默认的打印页面设置</P>
<P>然后 运行下面的程序</P>
<P>Sub DaYin()</P>
<P>Dim a As AcadLayer</P>
<P>For i = 0 To ThisDrawing.Layers.Count - 1<BR>&nbsp;&nbsp;&nbsp; ThisDrawing.Layers.Item(i).LayerOn = False<BR>&nbsp;&nbsp;&nbsp; ThisDrawing.Layers.Item(i).Plottable = False<BR>Next i</P>
<P>ThisDrawing.Layers("公共图层1").LayerOn = True '&lt;----------改成具体的公共层名字<BR>ThisDrawing.Layers("公共图层1").Plottable = True&nbsp; '&lt;----------改成具体的公共层名字<BR>ThisDrawing.Layers("公共图层2").LayerOn = True '&lt;----------改成具体的公共层名字<BR>ThisDrawing.Layers("公共图层2").Plottable = True&nbsp; '&lt;----------改成具体的公共层名字<BR>ThisDrawing.Layers("公共图层3").LayerOn = True '&lt;----------改成具体的公共层名字<BR>ThisDrawing.Layers("公共图层3").Plottable = True '&lt;----------改成具体的公共层名字</P>
<P>For Each a In ThisDrawing.Layers<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; If a.LayerOn = False Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a.LayerOn = True<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a.Plottable = True</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ThisDrawing.Plot.PlotToDevice<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If MsgBox("现在正在打印的图层是" + a.Name _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + ",先不要按确定,等打完了再按." + "如果发现打印格式不对,就按取消", _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vbOKCancel + vbInformation) = vbCancel Then Exit For<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a.LayerOn = False<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a.Plottable = False<BR>&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </P>
<P>Next a<BR>End Sub<BR></P>

daziduan 发表于 2006-1-15 02:23:00

<P>a nice work!</P>

mayuezxl 发表于 2006-1-15 10:49:00

太感谢你了,我马上试一下。

crazylsp 发表于 2012-7-15 19:53:28

本帖最后由 crazylsp 于 2012-7-15 19:55 编辑

感谢686楼主分享。
页: [1]
查看完整版本: [求助]如何打印所有图层