MSITStore:D:\Program%20Files\AutoCAD%202010\help\acad_aag.chm::/WSfacf1429558a55de2ab0a1008e4bf960-7c6d.htm">创建和编辑 AutoCAD 图元 > MSITStore:D:\Program%20Files\AutoCAD%202010\help\acad_aag.chm::/WS1a9193826455f5ff1a32d8d10ebc6b7ccc-6bcb.htm">使用图层、颜色和线型 > MSITStore:D:\Program%20Files\AutoCAD%202010\help\acad_aag.chm::/WS1a9193826455f5ff1a32d8d10ebc6b7ccc-6bca.htm"> 使用图层 >
用户可以遍历 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 |