指定图形的活动视口。 支持的平台:仅窗口 言论对当前活动视口所做的更改只有在将视口重置为活动视口后才会变得可见。若要重置活动视区,只需使用更新的视区对象调用此属性。 使用该属性确定视区当前是否处于活动状态。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) ) |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-8 19:51
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.