如何实现关闭已选择实体的图层??
<p>想编一个程序:</p><p>输入命令,从屏幕选择实体,程序判断已选实体的图层,然后将其关闭!</p><p>判高手指点一下~</p> Sub test()Dim Obj As Object
Dim PickP As Variant
ThisDrawing.Utility.GetEntity Obj, PickP, "选择要关闭该层的图元:"
ThisDrawing.Layers.Item(Obj.Layer).LayerOn = False
End Sub
<p>多谢啦</p><p>还想问问如果用选择集的方法可以么?</p><p>同时实现cad的框选功能,并且像输入cad命令一样,敲选回车后才关闭图层~</p> 选择集当然可以,只是选择集里的实体不一定都在一个层上,这样就要遍历选择集来处理 多谢斑竹,我写了如下代码:看看有什么问题哦
Sub test()
Dim ssetobj As AcadSelectionSet
Dim s As AcadSelectionSet
On Error Resume Next
Set ssetobj = ThisDrawing.SelectionSets.Add("egua")
If Err Then
Err.Clear
Set ssetobj = ThisDrawing.SelectionSets.Item("egua")
End If
ssetobj.Clear
ssetobj.SelectOnScreen
For Each s In ssetobj
ThisDrawing.Layers.Item(s.Layer).LayerOn = False
Next s
End Sub Sub test()
Dim ssetobj As AcadSelectionSet
Dim s As AcadSelectionSet这里有问题,要改成这样:Dim s As AcadEntity
On Error Resume Next
Set ssetobj = ThisDrawing.SelectionSets.Add("egua")
If Err Then
Err.Clear
Set ssetobj = ThisDrawing.SelectionSets.Item("egua")
End If
ssetobj.Clear
ssetobj.SelectOnScreen
For Each s In ssetobj
ThisDrawing.Layers.Item(s.Layer).LayerOn = False
Next s
End Sub
页:
[1]