VB中设置图层为当前图层及如何设置图层颜色。
VB中设置图层为当前图层及如何设置图层颜色。 Sub addlay(name As String, co As Long)<br/>Dim lay0 As AcadLayer '定义作为图层的变量<br/>Dim lay1 As AcadLayer<br/>Dim findlay As Long<br/>findlay = 0 '寻找图层的结果的变量,0没有找到,1找到<br/>For Each lay0 In ThisDrawing.Layers '在所有的图层中进行循环<br/> If lay0.name = name Then '如果找到图层名<br/> findlay = 1 '把变量改为1标志着图层已经找到<br/> If Not lay0.LayerOn Then lay0.LayerOn = True '打开<br/> ThisDrawing.ActiveLayer = lay0 '把当前图层设为已经存在的图层<br/> Exit For '结束寻找<br/> End If<br/>Next lay0<br/>If findlay = 0 Then '没有找到图层<br/> Set lay1 = ThisDrawing.Layers.Add(name) '增加一个名为“临时图层”的图层<br/> lay1.color = co '图层设置为黄色<br/> ThisDrawing.ActiveLayer = lay1 '将当前图层设置为新建图层<br/>End If<br/>End Sub lay0 As AcadLayer 用户类型未定义是怎么回事?
页:
[1]