SetGridSpacing メソッド(ActiveX)

ビューポートのグリッド間隔を設定します。

サポートされているプラットフォーム: Windows のみ

構文と要素

VBA:

object.SetGridSpacing XSpacing, YSpacing
object

タイプ: PViewportViewport

このメソッドが適用されるオブジェクト。

XSpacing

アクセス: 入力のみ

タイプ: 倍精度浮動小数点数型

ビューポートでのグリッドの X 間隔を設定します。

YSpacing

アクセス: 入力のみ

タイプ: 倍精度浮動小数点数型

ビューポートでのグリッドの Y 間隔を設定します。

戻り値(RetVal)

戻り値はありません。

注意

追加の注意はありません。

VBA:

Sub Example_SetGridSpacing()
    ' This example turns on the grid for the current viewport.
    ' It then finds the current grid spacing, and changes that spacing.
    
    ' Find the current active viewport
    Dim viewportObj As AcadViewport
    Set viewportObj = ThisDrawing.ActiveViewport
    
    ' Turn on the grid and reset the viewport to see it come on.
    viewportObj.GridOn = True
    ThisDrawing.ActiveViewport = viewportObj
    
    ' Find the current grid spacing
    Dim XSpacing As Double
    Dim YSpacing As Double
    
    viewportObj.GetGridSpacing XSpacing, YSpacing
    MsgBox "X =" & XSpacing & ", Y =" & YSpacing, , "SetGridSpacing Example"
    
    ' Change the grid spacing
    XSpacing = XSpacing * 0.5
    YSpacing = YSpacing * 0.5
    viewportObj.SetGridSpacing XSpacing, YSpacing
    ThisDrawing.ActiveViewport = viewportObj
    MsgBox "X =" & XSpacing & ", Y =" & YSpacing, , "SetGridSpacing Example"
   
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_SetGridSpacing()
    ;; This example turns on the grid for the current viewport.
    ;; It then finds the current grid spacing, and changes that spacing.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    ;; Find the current active viewport
    (setq viewportObj (vla-get-ActiveViewport doc))
    
    ;; Turn on the grid and reset the viewport to see it come on.
    (vla-put-GridOn viewportObj :vlax-true)
    (vla-put-ActiveViewport doc viewportObj)
    
    ;; Find the current grid spacing
    (vla-GetGridSpacing viewportObj 'XSpacing 'YSpacing)
    (alert (strcat "X =" (rtos XSpacing 2) ", Y =" (rtos YSpacing 2)))
    
    ;; Change the grid spacing
    (vla-SetGridSpacing viewportObj (* XSpacing 0.5) (* YSpacing 0.5))
    (vla-put-ActiveViewport doc viewportObj)

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