About Resetting Active Objects (ActiveX)

Changes to most active objects, such as the active layer and active linetype, appear immediately.

However, there are several active objects that must be reset for changes to appear. These objects are the active text style, the active user coordinate system (UCS), and the active viewport. If changes are made to any of these objects, the object must be reset, and the Regen method must be called for the changes to appear.

To reset these objects, simply set the ActiveTextStyle, ActiveUCS, or ActiveViewport property, using the updated object.

Reset the active viewport

The following example changes the display of the grid in the active viewport and then resets the viewport as the active viewport to display the change.

AutoLISP
(vl-load-com)
(defun c:Ch3_ResetActiveViewport()
    (setq acadObj (vlax-get-acad-object)
          doc (vla-get-ActiveDocument acadObj)
          vportObj (vla-get-ActiveViewport doc))

    ;; Toggle the setting of the grid display
    ;; for the active viewport
    (vla-put-GridOn vportObj (if (= (vla-get-GridOn vportObj) :vlax-true) 
                                    :vlax-false :vlax-true))

    ;; Reset the active viewport
    (vla-put-ActiveViewport doc vportObj)
)
VBA (AutoCAD Only)
Sub Ch3_ResetActiveViewport()
  ' Toggle the setting of the grid display
  ' for the active viewport
  ThisDrawing.ActiveViewport.GridOn = Not (ThisDrawing.ActiveViewport.GridOn)

  ' Reset the active viewport
  ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport
End Sub