判断图层是否存在的方法.
本帖最后由 作者 于 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/> If Trim(AA.Name) = Trim(tt) Then <br/> abc = True <br/> Exit Function <br/> End If <br/>Next AA <br/>abc = False <br/><br/>End Function <br/><br/>Sub lslsls() <br/> Dim gg <br/> gg = abc("尺寸线") <br/> Dim AA As AcadLayer <br/> If gg = False Then <br/> Set AA = ThisDrawing.Layers.Add("尺寸线") <br/> End If <br/> Debug.Print gg <br/>End Sub</p><p>.Layers.Item(ii).Name可以直接调用到图层名</p><p> For ii = 0 To ThisDrawing.ModelSpace.Count<br/> Debug.Print ThisDrawing.Layers.Item(ii).Name<br/> Next ii</p>
页:
[1]