- UID
- 433376
- 积分
- 61
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2006-5-6
- 最后登录
- 1970-1-1
|
发表于 2007-10-29 17:51:17
|
显示全部楼层
使用DisplayPlotPreview方法,不过很复杂。
随便贴一段代码,是在VB中使用的
Dim ptMin As Variant, ptMax As Variant
Dim ent As AcadEntity
Dim i As Integer, N As Integer
For i = 0 To lstPlotFiles.ListCount - 1
N = 1
If Len(Dir(lstPlotFiles.List(i))) = 0 Then '检查文件是否存在
MsgBox "文件" & lstPlotFiles.List(i) & "不存在!"
End If
Call OpenFile(lstPlotFiles.List(i)) '打开或激活第i个图形文件
Set objDoc = acadapp.ActiveDocument.Application.ActiveDocument
acadapp.ActiveDocument.Application.ZoomExtents '实现范围缩放
'确保当前布局是模型空间
Set objLayout = objDoc.Layouts.Item("Model")
Set objPlot = objDoc.Plot
Call SetPlotConfiguration '设置打印选项(☆必须步骤)
objLayout.CopyFrom objPlotConfiguration '将打印设置应用到当前图形
objDoc.Regen acAllViewports '所有视口重生成当前图形
For Each ent In acadapp.ActiveDocument.ModelSpace '对当前图形模型空间中的所有打印区域进行完全预览
ent.GetBoundingBox ptMin, ptMax '获得每个Document(图形)对象最小包围框的两个角点
objLayout.SetWindowToPlot ptMin, ptMax '设置打印窗口
objDoc.Regen acAllViewports '所有视口重生成当前图形
objPlot.DisplayPlotPreview acFullPreview '完全预览当前的区域
N = N + 1
If N > 1 Then '每次只预览当前激活窗口
objLayout.CopyFrom objOriginalPC '恢复原来的打印设置
Form8.Show '显示打印界面
Call SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3) '某窗体始终最上层显示
Call SetWindowPos(Me.hwnd, -2, 0, 0, 0, 0, 3) '某窗体恢复正常状态
Exit Sub
End If
Next ent
请到“测量空间”下载“横纵断面图及施工测量”,其中有一“批量打印”模块中有打印预览功能。
黄玉宏 二○○七年十月二十九日 |
|