有一套程序,主要功能是关闭引用背景图的相关图层的。由用户在TEXTBOX1中输入需要关闭的图层名称,几个图层之间要用;分隔。由于所有引用都有引用名称如XREF1等。如图层:XREF1│0,故关闭时需要从图层名称的后几位开始。程序如下:
Private Sub CommandButton1_Click() Dim layname As String Dim z As Integer Dim ii As Integer Dim lay4 As AcadLayer z = 1 For ii = 1 To Len(TextBox1.Text) ii = InStr(z, TextBox1.Text, Chr(59)) If ii = 0 Then layname = Mid(TextBox1.Text, z, (Len(TextBox1.Text))) ii = Len(TextBox1.Text) + 1 Else layname = Mid(TextBox1.Text, z, ii - z) z = ii + 1 End If For Each lay4 In ThisDrawing.Layers If Mid(lay4.Name, 7) = layname Then lay4.LayerOn = False Exit For End If Next lay4 Next ii End Sub
程序运行后有以下问题:1、图层名为单独数字的关不了,如XREF1│9;2、图层名为汉字的关不了,如XREF1│设备。
请高手指点,谢谢! |