CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2025 开发者帮助

ViewportOn 属性 (ActiveX)

2024-5-18 19:22| 发布者: admin| 查看: 115| 评论: 0|原作者: admin|来自: AutoCAD

ViewportOn 属性 (ActiveX)

指定视口的显示状态。

支持的平台:仅限 Windows

签名

VBA:

object.ViewportOn
对象

类型: PViewport

此属性应用于的对象。

属性值

只读:

类型:布尔

  • True:视口已打开。
  • False:视口关闭。

言论

若要打开或关闭视口的显示控件,请使用该方法。Display

例子

VBA:

Sub Example_ViewportOn()
    ' This example creates two new paper space viewports.
    ' It then checks the status of the viewports.
    
    Dim pviewportObj1 As AcadPViewport
    Dim pviewportObj2 As AcadPViewport
    Dim center(0 To 2) As Double
    Dim width As Double
    Dim height As Double
    
    ' Define the paper space viewport
    center(0) = 3: center(1) = 3: center(2) = 0
    width = 10
    height = 10
    
    ' Change from model space to paper space
    ThisDrawing.ActiveSpace = acPaperSpace
    
    ' Create the paper space viewports
    Set pviewportObj1 = ThisDrawing.PaperSpace.AddPViewport(center, width, height)
    center(0) = 8: center(1) = 8: center(2) = 0
    width = 10
    height = 10
    Set pviewportObj2 = ThisDrawing.PaperSpace.AddPViewport(center, width, height)
    
    ' Before making a paper space viewport active,
    ' the mspace property needs to be True
    pviewportObj1.DISPLAY (True)
    ThisDrawing.mspace = True
    ThisDrawing.ActivePViewport = pviewportObj1
    ThisDrawing.Regen acAllViewports
    
    MsgBox "pviewportObj1 is " & (IIf(pviewportObj1.ViewportOn, "on.", "not on.")) & vbCrLf & _
           "pviewportObj2 is " & (IIf(pviewportObj2.ViewportOn, "on.", "not on."))
    
    ' Now turn on pviewportObj2 as well
    pviewportObj2.DISPLAY (True)
    MsgBox "pviewportObj1 is " & (IIf(pviewportObj1.ViewportOn, "on.", "not on.")) & vbCrLf & _
           "pviewportObj2 is " & (IIf(pviewportObj2.ViewportOn, "on.", "not on."))
    
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_ViewportOn()
    ;; This example creates two new paper space viewports.
    ;; It then checks the status of the viewports.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Define the paper space viewport
    (setq center (vlax-3d-point 3 3 0)
          width 10
          height 10)
    
    ;; Change from model space to paper space
    (vla-put-ActiveSpace doc acPaperSpace)
    
    ;; Create the paper space viewports
    (setq paperSpace (vla-get-PaperSpace doc))
    (setq pviewportObj1 (vla-AddPViewport paperSpace center width height))
  
    (setq center (vlax-3d-point 8 8 0)
          width 10
          height 10)

    (setq pviewportObj2 (vla-AddPViewport paperSpace center width height))
    
    ;; Before making a paper space viewport active,
    ;; the mspace property needs to be True
    (vla-Display pviewportObj1 :vlax-true)

    (vla-put-MSpace doc :vlax-true)
    (vla-put-ActivePViewport doc pviewportObj1)
    (vla-Regen doc acAllViewports)
    
    (alert (strcat "pviewportObj1 is " (if (= (vla-get-ViewportOn pviewportObj1) :vlax-true) "on." "not on.")
                   "\npviewportObj2 is " (if (= (vla-get-ViewportOn pviewportObj2) :vlax-true) "on." "not on.")))
    
    ;; Now turn on pviewportObj2 as well
    (vla-Display pviewportObj2 :vlax-true)

    (alert (strcat "pviewportObj1 is " (if (= (vla-get-ViewportOn pviewportObj1) :vlax-true) "on." "not on.")
                   "\npviewportObj2 is " (if (= (vla-get-ViewportOn pviewportObj2) :vlax-true) "on." "not on.")))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-12-15 22:32

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部