田草博客

互联网田草博客


网友交流QQ群:11740834 需注明申请加入原因

微信 公众号:ByCAD

邮箱:tiancao1001x126.com
ByCAD,微信公众号
首页 | 普通 | 电脑 | AutoCAD | VB/VB.NET | FLash | 结构 | 建筑 | 电影 | BIM | 规范 | 软件 | ID
-随机-|-分布-
-博客论坛-|-﨣﨤﨧﨨-
-网站导航-|-规范下载-
-BelovedFLash欣赏-

用户登陆
用户:
密码:
 

站点日历
73 2024 - 4 48
 123456
78910111213
14151617181920
21222324252627
282930


站点统计

最新评论



今天第一次为国产DVD买单,很是失望? 《建筑工程建筑面积计算规范》有关问题问卷
未知 CAD VBA 实现图纸的快速打印   [ 日期:2007-08-08 ]   [ 来自:本站原创 ]  HTML
CAD VBA 实现图纸的快速打印



按此在新窗口打开图片



'快速打印
Function KSDY(E As AcadEntity)

    Dim ptMax
    Dim ptMin
    E.GetBoundingBox ptMin, ptMax '返回的是世界坐标

    ReDim Preserve ptMin(0 To 1)
    ReDim Preserve ptMax(0 To 1)
    
    
    
    ' 设置打印比例为“布满图纸”
    ThisDrawing.ActiveLayout.StandardScale = acScaleToFit
    
    ThisDrawing.ActiveLayout.SetWindowToPlot ptMin, ptMax
    ' 设置打印类型
    ThisDrawing.ActiveLayout.PlotType = acWindow

    If Me.OptionButton4.Value = True Then
        '启用打印预览
        
        ThisDrawing.ActiveLayout.GetWindowToPlot ptMin, ptMax
        
        ThisDrawing.Plot.DisplayPlotPreview acFullPreview
    Else
        '打印当前的区域
        '若选中“打印到文件”
        If PlotTofile_CheckBox.Value Then
            MsgBox "1"
            MsgBox PlotFilesPath_ComboBox.Text & ThisDrawing.Name & "-" & n & ".plt"
            If PlotFilesPath_ComboBox.Text = "" Then PlotFilesPath_ComboBox.Text = GetPath
            ThisDrawing.Plot.PlotToFile PlotFilesPath_ComboBox.Text & ThisDrawing.Name & "-" & n & ".plt"
            n = n + 1
        Else
            ThisDrawing.Plot.PlotToDevice ThisDrawing.ModelSpace.Layout.ConfigName
        End If
    End If
End Function


[本日志由 田草 于 2008-08-03 12:19 AM 编辑]


引用这个评论 157787698 于 2009-11-09 04:18 PM 发表评论: 
请问:
上述打印区域片的问题有没有解决?
目前我也遇到这个问题,想尽了各种办法绝无法解决
如果有解决办法,请指点一下,谢谢

引用这个评论 tiancao1001 于 2009-10-30 09:01 AM 发表评论: 
没有这么智能,

引用这个评论 xiaoshi112 于 2009-10-29 10:50 PM 发表评论: 
可不可以让打印的时候把图纸自动的拼在一起打印,这样更加节省图纸?

引用这个评论 xiaoshi112 于 2009-10-29 10:49 PM 发表评论: 
可不可以让打印的时候把图纸自动的拼在一起打印,这样更加节省图纸?

引用这个评论 tiancao1001 于 2008-12-02 01:39 PM 发表评论: 
'快速打印
Function KSDY2(P1 As Variant, P2 As Variant)


    Dim PtMin As Variant
    Dim PtMax As Variant
    PtMin = P1
    PtMax = P2
    
    ReDim Preserve PtMin(0 To 1)
    ReDim Preserve PtMax(0 To 1)
    
    
    
    ' 设置打印比例为“布满图纸”
    ThisDrawing.ActiveLayout.StandardScale = acScaleToFit
    
    ThisDrawing.ActiveLayout.SetWindowToPlot PtMin, PtMax
    ' 设置打印类型为窗口
    ThisDrawing.ActiveLayout.PlotType = acWindow
    '设置为居中打印
    ThisDrawing.ActiveLayout.CenterPlot = True

    If Me.OptionButton4.Value = True Then
        '启用打印预览
        
        ThisDrawing.ActiveLayout.GetWindowToPlot PtMin, PtMax
        
        ThisDrawing.Plot.DisplayPlotPreview acFullPreview
    Else
        '打印当前的区域
        '若选中“打印到文件”
        If PlotTofile_CheckBox.Value Then
            If PlotFilesPath_ComboBox.text = "" Then PlotFilesPath_ComboBox.text = GetPath
            ThisDrawing.Plot.PlotToFile PlotFilesPath_ComboBox.text & ThisDrawing.Name & "-" & N & ".plt"
            N = N + 1
        Else
            ThisDrawing.Plot.PlotToDevice ThisDrawing.ModelSpace.Layout.ConfigName
        End If
    End If
End Function

引用这个评论 田草 于 2008-03-08 09:42 AM 发表评论: 
我发现打印偏移和图纸的可打印区域有关系,但是我不知道怎么用vba获得图纸的可打印区域,

引用这个评论 田草 于 2008-03-07 05:54 PM 发表评论: 
 '不知道为什么, 'ThisDrawing.ActiveLayout.CenterPlot = True 这句有的时候,出现PlotOrigin 不定,
'而且使用GetBoundingBox获取对象的角点有的时候也不太好用。还是使用getPoint比较实在。
Sub xPrint2()
    Dim P1 As Variant
    Dim P2 As Variant
    Dim W As Double
    Dim H As Double
    Dim W1 As Double
    Dim H1 As Double
    Dim xOrigin(1) As Double
    Dim xScale(1) As Double
    Dim S As Double
    Dim R
    On Error Resume Next
    P1 = ThisDrawing.Utility.GetPoint(, "打印窗口的角点:")
    P2 = ThisDrawing.Utility.GetPoint(P1, "打印窗口的另一个角点:")
E:
    On Error GoTo F:
    ReDim Preserve P1(0 To 1)
    ReDim Preserve P2(0 To 1)
    ThisDrawing.ActiveLayout.GetPaperSize W, H
    Prompt str(W) & " / " & str(H) & vbCrLf
    W1 = Abs(P1(0) - P2(0)): H1 = Abs(P1(1) - P2(1))
    Prompt str(W1) & " / " & str(H1) & vbCrLf
    R = ThisDrawing.ActiveLayout.PlotRotation
    
    If R = ac0degrees Or R = ac180degrees Then
        xScale(0) = W1 / W
        xScale(1) = H1 / H
        If xScale(0) >= xScale(1) Then
           S = xScale(0)
        Else
           S = xScale(1)
        End If
        Prompt str(S) & vbCrLf
        ThisDrawing.ActiveLayout.SetCustomScale 1, S
        xOrigin(0) = Abs(W1 / S - W) / 2
        Prompt str(xOrigin(0)) & vbCrLf
        xOrigin(1) = Abs(H1 / S - H) / 2
        Prompt str(xOrigin(1)) & vbCrLf
    ElseIf R = ac90degrees Or R = ac270degrees Then
        xScale(0) = H1 / W
        xScale(1) = W1 / H
        If xScale(0) >= xScale(1) Then
           S = xScale(0)
        Else
           S = xScale(1)
        End If
        Prompt str(S) & vbCrLf
        ThisDrawing.ActiveLayout.SetCustomScale 1, S
        xOrigin(0) = Abs(H1 / S - W) / 2
        Prompt str(xOrigin(0)) & vbCrLf
        xOrigin(1) = Abs(W1 / S - H) / 2
        Prompt str(xOrigin(1)) & vbCrLf
    End If
    ThisDrawing.ActiveLayout.PlotOrigin = xOrigin
    ThisDrawing.ActiveLayout.SetWindowToPlot P1, P2
    ThisDrawing.ActiveLayout.GetWindowToPlot P1, P2
    ThisDrawing.ActiveLayout.PlotType = acWindow
    ThisDrawing.Plot.DisplayPlotPreview acFullPreview
    'ThisDrawing.Plot.PlotToDevice ThisDrawing.ModelSpace.Layout.ConfigName
    P1 = ThisDrawing.Utility.GetPoint(, "打印窗口的角点:")
    P2 = ThisDrawing.Utility.GetPoint(P1, "打印窗口的另一个角点:")
    GoTo E:
F:
End Sub

引用这个评论 田草 于 2008-02-21 02:59 PM 发表评论: 
你自己用vba记录下来,再用vba导入啊。

引用这个评论 liuningbo00 于 2008-02-21 02:47 PM 发表评论: 
请问VBA 应用上一次打印设置 代码如何写?麻烦指教,多谢。。。

引用这个评论 田草 于 2007-10-29 01:52 PM 发表评论: 
不知道 到底是什么了,
打印原点和 打印区域窗口坐标 到底是个什么关系呢?
regen也没有用,
居中打印,vba的命令好像有的时候不执行。

引用这个评论 田草 于 2007-10-27 11:18 PM 发表评论: 
还是错了,今天才发现,不出现打印偏移,很简单的方法就是 regen命名。


引用这个评论 田草 于 2007-08-26 03:47 PM 发表评论: 
不是世界坐标 ,至于是用户坐标还是显示坐标 或者空间布局坐标 我也说不清楚。

设置ThisDrawing.ModelSpace.Layout.PlotOrigin 这个是不行的。

引用这个评论 0527 于 2007-08-26 03:46 PM 发表评论: 
???


引用这个评论 田草 于 2007-08-25 09:10 PM 发表评论: 
在百度空间上还看到一位网友的做法是
   '重新指定原点,防止漂移
    ThisDrawing.ModelSpace.Layout.PlotOrigin = originalValue
…………

    '必须保存原始原点,否则打印会随机飘动?
    Dim originalValue As Variant
    originalValue = ThisDrawing.ModelSpace.Layout.PlotOrigin


他所说的随机漂移肯定是错的,但是他的方法不知道可行否,回去验证一下,再告诉大家。

引用这个评论 田草 于 2007-08-25 08:43 PM 发表评论: 
VBA中GetPoint以及GetBoundingBox返回的是都是世界坐标(WCS),而ThisDrawing.ModelSpace.Layout.SetWindowToPlot中使用的却是显示坐标(DCS),
我们可以使用ThisDrawing.Utility.TranslateCoordinates(PtMax, acWorld, acDisplayDCS, False)将世界坐标转换成显示坐标,这样就不会出现打印的时候图像出现偏移。

发表评论 - 不要忘了输入验证码哦!
作者: 用户:  密码:   注册? 验证:  防止恶意留言请输入问题答案:1*5=?  
评论:

禁止表情
禁止UBB
禁止图片
识别链接
识别关键字

字体样式 文字大小 文字颜色
插入粗体文本 插入斜体文本 插入下划线
左对齐 居中对齐 右对齐
插入超级链接 插入邮件地址 插入图像
插入 Flash 插入代码 插入引用
插入列表 插入音频文件 插入视频文件
插入缩进符合
点击下载按钮 下标 上标
水平线 简介分割标记
表  情
 
Tiancao Blog All Rights Reserved 田草博客 版权所有
Copyright ©