CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

限制属性 (ActiveX)

2023-1-3 12:07| 发布者: admin| 查看: 394| 评论: 0|来自: AutoCAD

摘要: 指定绘图限制。

指定绘图限制。

支持的平台:仅窗口

签名

工 务 局:

object.Limits
对象

类型:数据库文档

此属性适用的对象。

属性值

只读:

类型:变体(双打数组)

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

言论

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

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

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

例子

工 务 局:

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

Visual 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 )

GMT+8, 2024-5-19 15:00

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部