図面のアクティブなビューポートを指定します。
サポートされているプラットフォーム: Windows のみ
現在のアクティブなビューポートへの変更は、ビューポートがアクティブなビューポートとしてリセットされた後にのみ反映されます。アクティブなビューポートをリセットするには変更されたビューポート オブジェクトを使ってこのプロパティを呼び出すだけです。
StatusID プロパティを使って、ビューポートが現在アクティブであるかどうかを確認します。
既存のビューポートの中から、1 つビューポートを選択することができます。それにはまず、Name プロパティを使って、希望のビューポートがある環境設定の名前を確認します。さらに、ビューポート環境設定が分割されている場合、その設定上の各ビューポートは LowerLeftCorner プロパティと UpperRightCorner プロパティで識別できます。
LowerLeftCorner プロパティと UpperRightCorner プロパティは、画面上でビューポートのグラフィックスの位置を示します。これらのプロパティを、次のように定義します(例として 4 分割を示します)。
ビューポート 1-LowerLeftCorner = (0, .5), UpperRightCorner = (.5, 1)
ビューポート 2 -LowerLeftCorner = (.5, .5), UpperRightCorner = (1, 1)
ビューポート 3-LowerLeftCorner = (0, 0), UpperRightCorner = (.5, .5)
ビューポート 4-LowerLeftCorner = (.5, 0), UpperRightCorner = (1, .5)
VBA:
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) )