Plottable 示例

使用 VBA 以外的其它编程语言

Sub Example_Plottable()
    ' This example creates a new layer called "New_Layer".  It then uses
    ' the Plottable property of each Layer to display whether or not that layer
    ' is plottable.  The user has the ability to toggle the plottable state
    ' for each layer, and the final plottable 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 plottable or not
    
    For Each tempLayer In ThisDrawing.Layers
        If tempLayer.Plottable Then     ' Determine if this layer is plottable
            If MsgBox("The layer '" & tempLayer.name & "' will plot.  Would you like to turn off plotting for this layer?", vbYesNo & vbQuestion) = vbYes Then
                tempLayer.Plottable = False     ' Change plottable state
            End If
        Else
            If MsgBox("The layer '" & tempLayer.name & "' will not plot.  Would you like to turn on plotting for this layer?", vbYesNo & vbQuestion) = vbYes Then
                tempLayer.Plottable = True      ' Change plottable state
            End If
        End If
    Next
    
    ' Display the new plottable status of the layers in this drawing
    
    For Each tempLayer In ThisDrawing.Layers
        ' Determine if this layer is plottable
        If tempLayer.Plottable Then
            msg = msg & "The layer '" & tempLayer.name & "' will plot." & vbCrLf
        Else
            msg = msg & "The layer '" & tempLayer.name & "' will not plot." & vbCrLf
        End If
    Next

    MsgBox msg
End Sub