设置视区的网格间距。 支持的平台:仅窗口 签名工 务 局: object.SetGridSpacing XSpacing, YSpacing 返回值(RetVal)无返回值。 言论没有额外的评论。 例子工 务 局: 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)))
)
|
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-29 05:58
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.