CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

设置网格间距方法 (ActiveX)

2023-1-4 01:55| 发布者: admin| 查看: 497| 评论: 0|来自: AutoCAD

摘要: 设置视区的网格间距。

设置视区的网格间距。

支持的平台:仅窗口

签名

工 务 局:

object.SetGridSpacing XSpacing, YSpacing
对象

类型:光伏端口视口

此方法适用的对象。

XS间距

访问:仅输入

类型:

视口中网格的X间距。

Y间距

访问:仅输入

类型:

视口中网格的Y间距。

返回值(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)))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-12 18:05

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部