都是lsp 来个vba的 Sub Example_layer() Dim layerobj As AcadLayer Dim obj As AcadEntity Dim pt As Variant '创建图层 For i = 1 To 10 Set layerobj = ThisDrawing.Layers.Add(CStr(i)) Next i On Error Resume Next ThisDrawing.Utility.GetEntity obj, pt, "选择对象:" If Err <> 0 Then Exit Sub End If Dim LayerName As String Do LayerName = ThisDrawing.Utility.GetString(5, "输入图层名:") For i = 0 To Layers.Count - 1 If UCase(Layers.Item(i).Name) = UCase(LayerName) Then obj.Layer = LayerName Exit Do End If Next i ThisDrawing.Utility.Prompt "输入的图层不存在,重新输入!" & vbCr Loop End Sub
|