GetSnapSpacing Method (ActiveX)

Gets the snap spacing for the viewport.

Supported platforms: Windows only

Signature

VBA:

object.GetSnapSpacing XSpacing, YSpacing
object

Type: PViewport, Viewport

The objects this method applies to.

XSpacing

Access: Output-only

Type: Double

The snap spacing for the X axis.

YSpacing

Access: Output-only

Type: Double

The snap spacing for the Y axis.

Return Value (RetVal)

No return value.

Remarks

No additional remarks.

Examples

VBA:

Sub Example_GetSnapSpacing()
    ' This example finds the current Snap spacing, and changes that spacing.
    
    ' Find the current active Model space viewport
    Dim viewportObj As AcadViewport
    Set viewportObj = ThisDrawing.ActiveViewport
    
    ' Turn on Snap spacing and reset the viewport.
    viewportObj.SnapOn = True
    ThisDrawing.ActiveViewport = viewportObj
    
    ' Find the current Snap spacing
    Dim XSpacing As Double
    Dim YSpacing As Double
    
    viewportObj.GetSnapSpacing XSpacing, YSpacing
    MsgBox "X =" & XSpacing & ", Y =" & YSpacing, Title:="GetSnapSpacing Example"
    
    ' Change the Snap spacing
    XSpacing = XSpacing * 0.5
    YSpacing = YSpacing * 0.5
    viewportObj.SetSnapSpacing XSpacing, YSpacing
    ThisDrawing.ActiveViewport = viewportObj
    MsgBox "X =" & XSpacing & ", Y =" & YSpacing, Title:="GetSnapSpacing Example"
   
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_GetSnapSpacing()
    ;; This example finds the current Snap spacing, and changes that spacing.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    ;; Find the current active Model space viewport
    (setq viewportObj (vla-get-ActiveViewport doc))
    
    ;; Turn on Snap spacing and reset the viewport.
    (vla-put-SnapOn viewportObj :vlax-true)
    (vla-put-ActiveViewport doc viewportObj)
    
    ;; Find the current Snap spacing
    (vla-GetSnapSpacing viewportObj 'XSpacing 'YSpacing)
    (alert (strcat "X =" (rtos XSpacing 2) ", Y =" (rtos YSpacing 2)))
    
    ;; Change the Snap spacing
    (vla-SetSnapSpacing viewportObj (* XSpacing 0.5) (* YSpacing 0.5))
    (vla-put-ActiveViewport doc viewportObj)

    (vla-GetSnapSpacing viewportObj 'XSpacing 'YSpacing)
    (alert (strcat "X =" (rtos XSpacing 2) ", Y =" (rtos YSpacing 2)))
)