CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

ActiveViewport Property (ActiveX)

2023-1-3 23:52| 发布者: admin| 查看: 458| 评论: 0|来自: AutoCAD

摘要: 指定图形的活动视口。

指定图形的活动视口。

支持的平台:仅窗口

签名

工 务 局:

object.ActiveViewport
对象

类型:文档

此属性适用的对象。

属性值

只读:

类型:视口

图形的活动视口。

言论

对当前活动视口所做的更改只有在将视口重置为活动视口后才会变得可见。若要重置活动视区,只需使用更新的视区对象调用此属性。

使用该属性确定视区当前是否处于活动状态。StatusID

您可以循环访问现有视区以查找特定视区。为此,首先使用属性标识所需视区所在的视口配置的名称。此外,如果视口配置已被拆分,则可以通过 andProperties 标识配置上的每个单独视口。NameLowerLeftCornerUpperRightCorner

属性表示视区在显示器上的图形位置。这些属性定义如下(以四向拆分为例):LowerLeftCornerUpperRightCorner



视口 1—= (0, .5),= (.5, 1)LowerLeftCornerUpperRightCorner

视口 2—= (.5, .5),= (1, 1)LowerLeftCornerUpperRightCorner

视口 3—= (0, 0),= (.5, .5)LowerLeftCornerUpperRightCorner

视口 4—= (.5, 0),= (1, .5)LowerLeftCornerUpperRightCorner

例子

工 务 局:

Sub Example_ActiveViewport()
    ' This example returns the current viewport.
    ' It creates a new viewport and makes it active, and
    ' Then it splits the viewport into four windows.
    ' It then takes one of the four windows, and splits that
    ' window horizontally into half.
    Dim currViewport As AcadViewport
    Dim newViewport As AcadViewport
    
    ' Returns current viewport of active document
    Set currViewport = ThisDrawing.ActiveViewport
    MsgBox "The current viewport is " & currViewport.name, vbInformation, "ActiveViewport Example"
    
    ' Create a new viewport and make it active
    Set newViewport = ThisDrawing.Viewports.Add("TESTVIEWPORT")
    ThisDrawing.ActiveViewport = newViewport
    MsgBox "The new active viewport is " & newViewport.name, vbInformation, "ActiveViewport Example"
    
    ' Split the viewport in four windows
    newViewport.Split acViewport4
    
    ' Make the newly split viewport active
    ThisDrawing.ActiveViewport = newViewport
    
    ' Note that current drawing layout will show four windows.
    ' However, only one of the windows will be active.
    ' The following code sets the lower-left corner window
    ' to be the active window and then splits that
    ' window into two horizontal windows.
    Dim entry
    For Each entry In ThisDrawing.Viewports
        If entry.name = "TESTVIEWPORT" Then
            Dim lowerLeft
            lowerLeft = entry.LowerLeftCorner
            If lowerLeft(0) = 0 And lowerLeft(1) = 0 Then
                Set newViewport = entry
                Exit For
            End If
        End If
    Next

    newViewport.Split acViewport2Horizontal
    ThisDrawing.ActiveViewport = newViewport
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_ActiveViewport()
    ;; This example returns the current viewport.
    ;; It creates a new viewport and makes it active, and
    ;; Then it splits the viewport into four windows.
    ;; It then takes one of the four windows, and splits that
    ;; window horizontally into half.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Returns current viewport of active document
    (setq currViewport (vla-get-ActiveViewport doc))
    (alert (strcat "The current viewport is " (vla-get-Name currViewport)))
    
    ;; Create a new viewport and make it active
    (setq viewports (vla-get-Viewports doc))
    (setq newViewport (vla-Add viewports "TESTVIEWPORT"))
    (vla-put-ActiveViewport doc newViewport)
    (alert (strcat "The new active viewport is " (vla-get-Name newViewport)))
    
    ;; Split the viewport in four windows
    (vla-Split newViewport acViewport4)
    
    ;; Make the newly split viewport active
    (vla-put-ActiveViewport doc newViewport)
    
    ;; Note that current drawing layout will show four windows.
    ;; However, only one of the windows will be active.
    ;; The following code sets the lower-left corner window
    ;; to be the active window and then splits that
    ;; window into two horizontal windows.
    (vlax-for each-viewport viewports
        (if (= (vla-get-Name each-viewport) "TESTVIEWPORT")
            (progn
                (setq lowerLeft (vla-get-LowerLeftCorner each-viewport))

                (if (and (= (vlax-safearray-get-element (vlax-variant-value lowerLeft) 0) 0)
                         (= (vlax-safearray-get-element (vlax-variant-value lowerLeft) 1) 0)
                    )
                    (setq newViewport each-viewport)
                )
            )
        )
    )
    (vla-Split newViewport acViewport2Horizontal)
    (vla-put-ActiveViewport doc newViewport)
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-19 14:38

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部