明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2147|回复: 3

问:在autocad对象模型中,怎样得到一个图幅的左下角和右上角的坐标(vba)??

[复制链接]
发表于 2002-11-20 13:39:00 | 显示全部楼层 |阅读模式
 楼主| 发表于 2002-11-20 13:41:00 | 显示全部楼层

急!!!!!!!!!!!!!!!!!!!ji

发表于 2002-11-20 20:15:00 | 显示全部楼层

获取图幅的左下角和右上角的坐标

可以用Document.Limits来获取,也可以系统变量LIMMAX和LIMMIN。
范例如下:
Sub Example_Limits()
    ' This example finds the current limits for the drawing.
    ' It then changes the limits for the drawing. The grid
    ' is turned on to show the limits.
   
    ' Turn on the grid for the active viewport
    ThisDrawing.ActiveViewport.GridOn = True
    ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport
   
    ' Find the current limits
    Dim currLimits As Variant

    currLimits = ThisDrawing.Limits
    MsgBox "The current drawing limits are " & vbCrLf _
           & "Lower-left corner " & ThisDrawing.Limits(0) & ", " & ThisDrawing.Limits(1) & vbCrLf _
           & "Upper-right corner " & ThisDrawing.Limits(2) & ", " & ThisDrawing.Limits(3), , "Limits Example"
           
    ' Change the limits
    Dim newLimits(0 To 3) As Double

    newLimits(0) = 2#: newLimits(1) = 2#: newLimits(2) = 4#: newLimits(3) = 4#
    ThisDrawing.Limits = newLimits
    ThisDrawing.Regen acActiveViewport
    MsgBox "The new drawing limits are " & vbCrLf _
           & "Lower-left corner " & ThisDrawing.Limits(0) & ", " & ThisDrawing.Limits(1) & vbCrLf _
           & "Upper-right corner " & ThisDrawing.Limits(2) & ", " & ThisDrawing.Limits(3), , "Limits Example"

   
    ' Reset the drawing limits
    ThisDrawing.Limits = currLimits
    ThisDrawing.Regen acActiveViewport
    MsgBox "The drawing limits have been reset to " & vbCrLf _
           & "Lower-left corner " & ThisDrawing.Limits(0) & ", " & ThisDrawing.Limits(1) & vbCrLf _
           & "Upper-right corner " & ThisDrawing.Limits(2) & ", " & ThisDrawing.Limits(3), , "Limits Example"

End Sub
发表于 2002-11-26 18:49:00 | 显示全部楼层

用GetBound函数

用GetBound函数
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-28 21:50 , Processed in 0.157035 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表