CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2023 开发者帮助

SnapOn 属性 (ActiveX)

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

SnapOn 属性 (ActiveX)

指定捕捉的状态。

支持的平台:仅限 Windows

签名

VBA:

object.SnapOn
对象

类型:PViewport视口

此属性应用于的对象。

属性值

只读:

类型:布尔

  • True:捕捉已打开。
  • False:捕捉已关闭。

言论

SnapOn使用当前对齐网格分辨率、旋转和样式激活对齐模式。若要更改捕捉栅格分辨率,请使用以下方法。若要更改对齐旋转,请使用属性。SetSnapSpacingSnapRotationAngle

捕捉网格是不可见的。使用该属性可显示单独的可见网格。GridOn

AutoCAD 会忽略透视图中的“捕捉”模式。

注意:此属性的值存储在 SNAPMODE 系统变量中。要更改捕捉样式,请使用 SNAPSTYL 系统变量。

例子

VBA:

Sub Example_SnapOn()
    ' This example toggles the setting of SnapOn.

    Dim viewportObj As AcadViewport
    
    ' Set the viewportObj variable to the activeviewport
    Set viewportObj = ThisDrawing.ActiveViewport
    
    ' Display the current setting of SnapOn
    MsgBox "Snap mode is: " & IIf(viewportObj.SnapOn, "On", "Off"), , "SnapOn Example"

    ' Toggle the setting of SnapOn
    viewportObj.SnapOn = Not (viewportObj.SnapOn)
    
    ' Reset the active viewport to see the change on the AutoCAD status bar
    ThisDrawing.ActiveViewport = viewportObj
    
    MsgBox "Snap mode is now: " & IIf(viewportObj.SnapOn, "On", "Off"), , "SnapOn Example"
    
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_SnapOn()
    ;; This example toggles the setting of SnapOn.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    ;; Set the viewportObj variable to the activeviewport
    (setq viewportObj (vla-get-ActiveViewport doc))
    
    ;; Display the current setting of SnapOn
    (alert (strcat "Snap mode is: " (if (= (vla-get-SnapOn viewportObj) :vlax-true) "On" "Off")))

    ;; Toggle the setting of SnapOn
    (vla-put-SnapOn viewportObj (if (= (vla-get-SnapOn viewportObj) :vlax-true) :vlax-false :vlax-true))
    
    ;; Reset the active viewport to see the change on the AutoCAD status bar
    (vla-put-ActiveViewport doc viewportObj)
    
    (alert (strcat "Snap mode is now: " (if (= (vla-get-SnapOn viewportObj) :vlax-true) "On" "Off")))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-6-27 16:11

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部