本帖最后由 作者 于 2008-7-27 18:26:14 编辑
下面程序是图层字符串是否在图层数据集内存在. 采用方法是通过在数据集内循环比较.
Function abc(tt As String) As Boolean Dim AA As AcadLayer
For Each AA In ThisDrawing.Layers If Trim(AA.Name) = Trim(tt) Then abc = True Exit Function End If Next AA abc = False
End Function
Sub lslsls() Dim gg gg = abc("尺寸线") Dim AA As AcadLayer If gg = False Then Set AA = ThisDrawing.Layers.Add("尺寸线") End If Debug.Print gg End Sub .Layers.Item(ii).Name可以直接调用到图层名 For ii = 0 To ThisDrawing.ModelSpace.Count Debug.Print ThisDrawing.Layers.Item(ii).Name Next ii |