ViewportDefault Property (ActiveX)

Specifies if the layer is to be frozen in new viewports.

Supported platforms: Windows only

Signature

VBA:

object.ViewportDefault
object

Type: Layer

The object this property applies to.

Property Value

Read-only: No

Type: Boolean

Remarks

No additional remarks.

Examples

VBA:

Sub Example_ViewportDefault()
    ' This example creates a new layer called "New_Layer".  It then uses
    ' the ViewportDefault property of each Layer to display whether or not that layer
    ' is frozen in new viewports.  The user has the ability to toggle whether or not
    ' each layer will be frozen in new viewports, and the final ViewportDefault status
    ' for all layers is displayed.
    
    Dim layerObj As AcadLayer, tempLayer As AcadLayer
    Dim msg As String

    ' Add the layer to the layers collection
    Set layerObj = ThisDrawing.Layers.Add("New_Layer")
    
    ' Make the new layer the active layer for the drawing
    ThisDrawing.ActiveLayer = layerObj
    
    ' Cycle through the layers and allow user to make them frozen in new viewports or not
    
    For Each tempLayer In ThisDrawing.Layers
        If tempLayer.ViewportDefault Then     ' Determine if this layer is fozen in new viewports
            If MsgBox("The layer '" & tempLayer.name & "' will be frozen in new viewports.  Would you like to make this layer unfrozen in new viewports?", vbYesNo & vbQuestion) = vbYes Then
                tempLayer.ViewportDefault = False     ' Change frozen state
            End If
        Else
            If MsgBox("The layer '" & tempLayer.name & "' will not be frozen in new viewports.  Would you like to make this layer frozen in new viewports?", vbYesNo & vbQuestion) = vbYes Then
                tempLayer.ViewportDefault = True      ' Change frozen state
            End If
        End If
    Next
    
    ' Display the new viewport freeze status of the layers in this drawing
    
    For Each tempLayer In ThisDrawing.Layers
        ' Determine if this layer is frozen in new viewports
        If tempLayer.ViewportDefault Then
            msg = msg & "The layer '" & tempLayer.name & "' will be frozen in new viewports." & vbCrLf
        Else
            msg = msg & "The layer '" & tempLayer.name & "' will not be frozen in new viewports." & vbCrLf
        End If
    Next

    MsgBox msg
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_ViewportDefault()
    ;; This example creates a new layer called "New_Layer".  It then uses
    ;; the ViewportDefault property of each Layer to display whether or not that layer
    ;; is frozen in new viewports.  The user has the ability to toggle whether or not
    ;; each layer will be frozen in new viewports, and the final ViewportDefault status
    ;; for all layers is displayed.

    ;; Add the layer to the layers collection
    (setq layerObj (vla-Add (vla-get-Layers doc) "New_Layer"))
    
    ;; Make the new layer the active layer for the drawing
    (vla-put-ActiveLayer doc layerObj)
    
    ;; Cycle through the layers and allow user to make them frozen in new viewports or not 
    (vlax-for tempLayer (vla-get-Layers doc)
        ;; Display the current new viewports layer state
        (if (= (vla-get-ViewportDefault tempLayer) :vlax-true)
            (alert (strcat "The layer '" (vla-get-Name tempLayer) "' is frozen for new viewports. Toggling state now."))
            (alert (strcat "The layer '" (vla-get-Name tempLayer) "' is not frozen for new viewports. Toggling state now."))
        )
        (vla-put-ViewportDefault tempLayer (if (= (vla-get-ViewportDefault tempLayer) :vlax-true) :vlax-false :vlax-true))
    )
    
    ;; Display the new viewport freeze status of the layers in this drawing
    (setq msg "")
    (vlax-for tempLayer (vla-get-Layers doc)
        ;; Determine if this layer is frozen in new viewports
        (if (= (vla-get-ViewportDefault tempLayer) :vlax-true)
            (setq msg (strcat msg "The layer '" (vla-get-Name tempLayer) "' will be frozen in new viewports.\n"))
            (setq msg (strcat msg "The layer '" (vla-get-Name tempLayer) "' will not be frozen in new viewports.\n"))
        )
    )

    (alert msg)
)