乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 64|回复: 3

关于打印

[复制链接]

26

主题

42

帖子

6

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
146
发表于 2006-8-22 22:08:00 | 显示全部楼层 |阅读模式
一段关于打印的程序:
Sub Example_Plot()
Dim ptmin As Variant, ptmax As Variant
Dim ent As AcadEntity
Dim i As Integer
For Each ent In ThisDrawing.ModelSpace
If TypeOf ent Is AcadBlockReference Then
If StrComp(ent.Name, "TK", vbTextCompare) = 0 Then
ent.GetBoundingBox ptmin, ptmax
ReDim Preserve ptmin(0 To 1)
ReDim Preserve ptmax(0 To 1)
ThisDrawing.ActiveLayout.SetWindowToPlot ptmin, ptmax
   Dim currentPlot As AcadPlot
    Set currentPlot = ThisDrawing.Plot
    currentPlot.PlotToDevice "d:\wxa3.pc3"
    i = i + 1
    End If
    End If
    Next ent
   
End Sub
程序运行后,没有任何反应!不知道为什么,请高手指点!
回复

使用道具 举报

16

主题

909

帖子

8

银币

中流砥柱

Rank: 25

铜币
973
发表于 2006-8-23 11:45:00 | 显示全部楼层
First you must have a block named "TK" in current drawing and a PC3 file name wxa.pc3 in D drive, then
Sub Example_Plot()
Dim ptmin As Variant, ptmax As Variant
Dim ent As AcadEntity
Dim i As Integer
For Each ent In ThisDrawing.ModelSpace
If TypeOf ent Is AcadBlockReference Then
If StrComp(ent.Name, "TK", vbTextCompare) = 0 Then
ent.GetBoundingBox ptmin, ptmax
ReDim Preserve ptmin(0 To 1)
ReDim Preserve ptmax(0 To 1)
ThisDrawing.ActiveLayout.SetWindowToPlot ptmin, ptmax
   Dim currentPlot As AcadPlot
    Set currentPlot = ThisDrawing.Plot
    ThisDrawing.ActiveLayout.PlotType = acWindow
    currentPlot.PlotToDevice "d:\wxa3.pc3"
    i = i + 1
    End If
    End If
    Next ent
   
End Sub
回复

使用道具 举报

26

主题

42

帖子

6

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

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

使用道具 举报

26

主题

42

帖子

6

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
146
发表于 2006-8-24 22:12:00 | 显示全部楼层
新编了一个程序如下:
Private Sub cmdOk_Click()
   Dim i As Integer
   Dim ii As Integer
   Dim zz As Integer
   Dim drn As String
   Dim drn1 As String
   Dim ptmin As Variant, ptmax As Variant
   Dim ent As AcadEntity
   Dim x As Integer
If lstFile.ListCount = 0 Then
MsgBox "请添加所要操作的图形!"
Exit Sub
End If
frmMain.hide
For i = 0 To lstFile.ListCount - 1
drn1 = lstFile.List(i)
Application.Documents.Open drn1
For Each ent In ThisDrawing.PaperSpace
If TypeOf ent Is AcadBlockReference Then
If StrComp(ent.Name, "TITLE", vbTextCompare)  0 Then
ent.GetBoundingBox ptmin, ptmax
Exit For
End If
End If
Next ent
ReDim Preserve ptmin(0 To 1)
ReDim Preserve ptmax(0 To 1)
    Dim currentPlot As AcadPlot
    Set currentPlot = ThisDrawing.Plot
    ThisDrawing.ActiveLayout.SetWindowToPlot ptmin, ptmax
    ThisDrawing.ActiveLayout.PlotType = acWindow
    If ComboBox1.Text = "ScaleToFit" Then
    ThisDrawing.ActiveLayout.StandardScale = acScaleToFit
    MsgBox TextBox2.Text
    ThisDrawing.ActiveLayout.StyleSheet = TextBox2.Text
    Else
    ThisDrawing.ActiveLayout.StandardScale = ac1_1
    ThisDrawing.ActiveLayout.StyleSheet = TextBox2.Text
    End If
   
       currentPlot.PlotToDevice TextBox1.Text
   Application.ActiveDocument.Close True, drn1
Next i
End Sub
程序运行到ThisDrawing.ActiveLayout.StyleSheet = TextBox2.Text处时出现错误,提示为INVALID INPUT.而TextBox2.Text的内容是笔表ctb文件的完整路径。删去此行时,程序运行完毕,但无笔表设置。请问为什么?
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-7-6 04:32 , Processed in 0.833927 second(s), 60 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表