CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2019 开发者帮助

Limits 属性 (ActiveX)

2024-5-18 17:53| 发布者: admin| 查看: 88| 评论: 0|原作者: admin|来自: AutoCAD

Limits 属性 (ActiveX)

指定绘图限制。

支持的平台:仅限 Windows

签名

VBA:

object.Limits
对象

类型:数据库文档

此属性应用于的对象。

属性值

只读:

类型:变体(双打数组)

包含四个值的数组。第一对值定义左下限的 XY 坐标,第二对值定义右上限的 XY 坐标。

言论

绘图极限是世界坐标系 (WCS) 中的二维点,分别表示左下角和右上角的极限。不能对 Z 方向施加限制。

绘图限制还控制可见栅格覆盖的绘图部分,并确定方法显示的最小区域。ZoomAll

注意:左下限控制 LIMMIN 系统变量。右上限控制 LIMMAX 系统变量。LIMCHECK 系统变量打开和关闭当前空间的限制检查。

例子

VBA:

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

可视化 LISP:

(vl-load-com)
(defun c: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.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    ;; Turn on the grid for the active viewport
    (vla-put-GridOn (vla-get-ActiveViewport doc) :vlax-true)
    (vla-put-ActiveViewport doc (vla-get-ActiveViewport doc))
    
    ;; Find the current limits
    (setq currLimits (vlax-variant-value (vla-get-Limits doc)))
    (setq tempLimits (vlax-safearray->list currLimits))
    (alert (strcat "The current drawing limits are"
                   "\nLower-left corner " (rtos (nth 0 tempLimits) 2) ", " (rtos (nth 1 tempLimits) 2)
                   "\nUpper-right corner " (rtos (nth 2 tempLimits) 2) ", " (rtos (nth 3 tempLimits) 2)))

    ;; Change the limits
    (setq newLimits (vlax-make-safearray vlax-vbDouble '(0 . 3)))
    (vlax-safearray-fill newLimits '(2 2 4 4))    
    (vla-put-Limits doc newLimits)
    (vla-Regen doc acActiveViewport)
    (setq tempLimits (vlax-safearray->list newLimits))
    (alert (strcat "The new drawing limits are"
                   "\nLower-left corner " (rtos (nth 0 tempLimits) 2) ", " (rtos (nth 1 tempLimits) 2)
                   "\nUpper-right corner " (rtos (nth 2 tempLimits) 2) ", " (rtos (nth 3 tempLimits) 2)))
  
    ;; Reset the drawing limits
    (vla-put-Limits doc currLimits)
    (vla-Regen doc acActiveViewport)
    (setq tempLimits (vlax-safearray->list currLimits))  
    (alert (strcat "The drawing limits have been reset to"
                   "\nLower-left corner " (rtos (nth 0 tempLimits) 2) ", " (rtos (nth 1 tempLimits) 2)
                   "\nUpper-right corner " (rtos (nth 2 tempLimits) 2) ", " (rtos (nth 3 tempLimits) 2)))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1   苏公网安备32011402011833)

GMT+8, 2024-12-15 22:02

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部