SnapOn 属性 (ActiveX) 
指定捕捉的状态。 支持的平台:仅限 Windows 属性值只读:不 类型:布尔 
 言论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")))
)
 | 
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1   苏公网安备32011402011833)
GMT+8, 2025-11-4 15:10
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.