兰州人 发表于 2008-7-26 22:48:00

判断图层是否存在的方法.

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