CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

SetView Method (ActiveX)

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

摘要: 将视口中的视图设置为 Views 集合对象中的已保存视图。

将视口中的视图设置为 Views 集合对象中的已保存视图。

支持的平台:仅窗口

签名

工 务 局:

object.SetView View
对象

类型:视口

此方法适用的对象。

视图

访问:仅输入

类型:视图

要设置的视图。

返回值(RetVal)

无返回值。

言论

没有额外的评论。

例子

工 务 局:

Sub Example_SetView()
    ' This example creates a new view.
    ' It then changes the active viewport to
    ' the newly created view.
    
    ' Create a new view
    Dim viewObj As AcadView
    Set viewObj = ThisDrawing.Views.Add("TESTVIEW")
    
    ' Set the view characteristics
    viewObj.center(0) = 374: viewObj.center(1) = 313
    viewObj.Width = 450
    viewObj.Height = 354
    
    ' Get the current active viewport
    Dim viewportObj As AcadViewport
    Set viewportObj = ThisDrawing.ActiveViewport
    MsgBox "Change to the saved view.", , "SetView Example"
       
    ' Set the view in the viewport
    viewportObj.SetView viewObj
    ThisDrawing.ActiveViewport = viewportObj
        
    ThisDrawing.Regen True
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_SetView()
    ;; This example creates a new view.
    ;; It then changes the active viewport to
    ;; the newly created view.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    ;; Create a new view
    (setq viewObj (vla-Add (vla-get-Views doc) "TESTVIEW"))
    
    ;; Set the view characteristics
    (setq centerPoint (vlax-make-safearray vlax-vbDouble '(0 . 1)))
    (vlax-safearray-fill centerPoint '(374 313))
    (vla-put-Center viewObj centerPoint)
    (vla-put-Width viewObj 450)
    (vla-put-height viewObj 354)
    
    ; Get the current active viewport
    (setq viewportObj (vla-get-ActiveViewport doc))
    (alert "Change to the saved view.")
       
    ;; Set the view in the viewport
    (vla-SetView viewportObj viewObj)
    (vla-put-ActiveViewport doc viewportObj)
        
    (vla-Regen doc :vlax-true)
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

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

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部