关于打印
<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> Dim currentPlot As AcadPlot<BR> Set currentPlot = ThisDrawing.Plot<BR> currentPlot.PlotToDevice "d:\wxa3.pc3"<BR> i = i + 1<BR> End If<BR> End If<BR> Next ent<BR> <BR>End Sub</P>
<P>程序运行后,没有任何反应!不知道为什么,请高手指点!</P> <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> Dim currentPlot As AcadPlot<BR> Set currentPlot = ThisDrawing.Plot<BR> ThisDrawing.ActiveLayout.PlotType = acWindow<BR> currentPlot.PlotToDevice "d:\wxa3.pc3"<BR> i = i + 1<BR> End If<BR> End If<BR> Next ent<BR> <BR>End Sub</P> 谢谢!该问题已解决。但是,新的问题又产生了:在d:\wxa3.pc3中已经设置了图纸的打印笔表,该笔表设置了各种颜色的线宽并设置了打印后全部为黑色(即黑白打印)。该笔表手动打印时效果正常。但是用上面的程序自动打印时,却没有体现出笔表的作用,打印出来为彩色的,无线宽区别的。 <P>新编了一个程序如下:</P>
<P>Private Sub cmdOk_Click()<BR> Dim i As Integer<BR> Dim ii As Integer<BR> Dim zz As Integer<BR> Dim drn As String<BR> Dim drn1 As String<BR> Dim ptmin As Variant, ptmax As Variant<BR> Dim ent As AcadEntity<BR> 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) <> 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> Dim currentPlot As AcadPlot<BR> Set currentPlot = ThisDrawing.Plot<BR> ThisDrawing.ActiveLayout.SetWindowToPlot ptmin, ptmax<BR> ThisDrawing.ActiveLayout.PlotType = acWindow<BR> If ComboBox1.Text = "ScaleToFit" Then<BR> ThisDrawing.ActiveLayout.StandardScale = acScaleToFit<BR> MsgBox TextBox2.Text<BR> ThisDrawing.ActiveLayout.StyleSheet = TextBox2.Text<BR> Else<BR> ThisDrawing.ActiveLayout.StandardScale = ac1_1<BR> ThisDrawing.ActiveLayout.StyleSheet = TextBox2.Text<BR> End If<BR> <BR> currentPlot.PlotToDevice TextBox1.Text<BR> 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]