weixin7944 发表于 2006-8-22 22:08:00

关于打印

<P>一段关于打印的程序:</P>
<P>Sub Example_Plot()<BR>Dim ptmin As Variant, ptmax As Variant<BR>Dim ent As AcadEntity<BR>Dim i As Integer<BR>For Each ent In ThisDrawing.ModelSpace<BR>If TypeOf ent Is AcadBlockReference Then<BR>If StrComp(ent.Name, "TK", vbTextCompare) = 0 Then<BR>ent.GetBoundingBox ptmin, ptmax<BR>ReDim Preserve ptmin(0 To 1)<BR>ReDim Preserve ptmax(0 To 1)<BR>ThisDrawing.ActiveLayout.SetWindowToPlot ptmin, ptmax<BR>&nbsp;&nbsp; Dim currentPlot As AcadPlot<BR>&nbsp;&nbsp;&nbsp; Set currentPlot = ThisDrawing.Plot<BR>&nbsp;&nbsp;&nbsp; currentPlot.PlotToDevice "d:\wxa3.pc3"<BR>&nbsp;&nbsp;&nbsp; i = i + 1<BR>&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; Next ent<BR>&nbsp;&nbsp;&nbsp; <BR>End Sub</P>
<P>程序运行后,没有任何反应!不知道为什么,请高手指点!</P>

alin 发表于 2006-8-23 11:45:00

<P>First you must have a block named "TK" in current drawing and a PC3 file name wxa.pc3 in D drive, then</P>
<P>Sub Example_Plot()<BR>Dim ptmin As Variant, ptmax As Variant<BR>Dim ent As AcadEntity<BR>Dim i As Integer<BR>For Each ent In ThisDrawing.ModelSpace<BR>If TypeOf ent Is AcadBlockReference Then<BR>If StrComp(ent.Name, "TK", vbTextCompare) = 0 Then<BR>ent.GetBoundingBox ptmin, ptmax<BR>ReDim Preserve ptmin(0 To 1)<BR>ReDim Preserve ptmax(0 To 1)<BR>ThisDrawing.ActiveLayout.SetWindowToPlot ptmin, ptmax<BR>&nbsp;&nbsp; Dim currentPlot As AcadPlot<BR>&nbsp;&nbsp;&nbsp; Set currentPlot = ThisDrawing.Plot<BR>&nbsp;&nbsp;&nbsp; ThisDrawing.ActiveLayout.PlotType = acWindow<BR>&nbsp;&nbsp;&nbsp; currentPlot.PlotToDevice "d:\wxa3.pc3"<BR>&nbsp;&nbsp;&nbsp; i = i + 1<BR>&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; Next ent<BR>&nbsp;&nbsp;&nbsp; <BR>End Sub</P>

weixin7944 发表于 2006-8-23 20:08:00

谢谢!该问题已解决。但是,新的问题又产生了:在d:\wxa3.pc3中已经设置了图纸的打印笔表,该笔表设置了各种颜色的线宽并设置了打印后全部为黑色(即黑白打印)。该笔表手动打印时效果正常。但是用上面的程序自动打印时,却没有体现出笔表的作用,打印出来为彩色的,无线宽区别的。

weixin7944 发表于 2006-8-24 22:12:00

<P>新编了一个程序如下:</P>
<P>Private Sub cmdOk_Click()<BR>&nbsp;&nbsp; Dim i As Integer<BR>&nbsp;&nbsp; Dim ii As Integer<BR>&nbsp;&nbsp; Dim zz As Integer<BR>&nbsp;&nbsp; Dim drn As String<BR>&nbsp;&nbsp; Dim drn1 As String<BR>&nbsp;&nbsp; Dim ptmin As Variant, ptmax As Variant<BR>&nbsp;&nbsp; Dim ent As AcadEntity<BR>&nbsp;&nbsp; Dim x As Integer<BR>If lstFile.ListCount = 0 Then<BR>MsgBox "请添加所要操作的图形!"<BR>Exit Sub<BR>End If<BR>frmMain.hide<BR>For i = 0 To lstFile.ListCount - 1<BR>drn1 = lstFile.List(i)<BR>Application.Documents.Open drn1<BR>For Each ent In ThisDrawing.PaperSpace<BR>If TypeOf ent Is AcadBlockReference Then<BR>If StrComp(ent.Name, "TITLE", vbTextCompare) &lt;&gt; 0 Then<BR>ent.GetBoundingBox ptmin, ptmax<BR>Exit For<BR>End If<BR>End If<BR>Next ent<BR>ReDim Preserve ptmin(0 To 1)<BR>ReDim Preserve ptmax(0 To 1)<BR>&nbsp;&nbsp;&nbsp; Dim currentPlot As AcadPlot<BR>&nbsp;&nbsp;&nbsp; Set currentPlot = ThisDrawing.Plot<BR>&nbsp;&nbsp;&nbsp; ThisDrawing.ActiveLayout.SetWindowToPlot ptmin, ptmax<BR>&nbsp;&nbsp;&nbsp; ThisDrawing.ActiveLayout.PlotType = acWindow<BR>&nbsp;&nbsp;&nbsp; If ComboBox1.Text = "ScaleToFit" Then<BR>&nbsp;&nbsp;&nbsp; ThisDrawing.ActiveLayout.StandardScale = acScaleToFit<BR>&nbsp;&nbsp;&nbsp; MsgBox TextBox2.Text<BR>&nbsp;&nbsp;&nbsp; ThisDrawing.ActiveLayout.StyleSheet = TextBox2.Text<BR>&nbsp;&nbsp;&nbsp; Else<BR>&nbsp;&nbsp;&nbsp; ThisDrawing.ActiveLayout.StandardScale = ac1_1<BR>&nbsp;&nbsp;&nbsp; ThisDrawing.ActiveLayout.StyleSheet = TextBox2.Text<BR>&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; currentPlot.PlotToDevice TextBox1.Text<BR>&nbsp;&nbsp; Application.ActiveDocument.Close True, drn1<BR>Next i</P>
<P>End Sub</P>
<P>程序运行到ThisDrawing.ActiveLayout.StyleSheet = TextBox2.Text处时出现错误,提示为INVALID INPUT.而TextBox2.Text的内容是笔表ctb文件的完整路径。删去此行时,程序运行完毕,但无笔表设置。请问为什么?</P>
页: [1]
查看完整版本: 关于打印