用户可以遍历 Layers 和 Linetypes 集合来查找图形中的所有图层和线型。
遍历 Layers 集合
以下代码遍历 Layers 集合,以收集图形中所有图层的名称,然后将这些名称显示在消息框中。
Sub Ch4_IteratingLayers()
Dim layerNames As String
Dim entry As AcadLayer
layerNames = ""
For Each entry In ThisDrawing.Layers
layerNames = layerNames + entry.Name + vbCrLf
Next
MsgBox "The layers in this drawing are: " + _
vbCrLf + layerNames
End Sub