SelectOnScreen没有效果是怎么回事
初学VBA,想定义一个选择集,并且在屏幕上选择多线段和直线添加到这个选择集中将selectonscreen的命令放在窗体的一个click事件中,F5运行程序,却不能对绘图空间中的图元进行选择,就直接进入到下一句
具体命令如下,大神帮忙分析下
Dim sset As AcadSelectionSet
Set sset = ThisDrawing.SelectionSets.Add("dxd")
Dim FilterType(0 To 3) As Integer
Dim FilterData(0 To 3) As Variant
'设置过滤器类型
FilterType(0) = -4
FilterType(1) = 0
FilterType(2) = 0
FilterType(3) = -4
'设置过滤数据
FilterData(0) = "<or"
FilterData(1) = "LWPolyline"
FilterData(2) = "line"
FilterData(3) = "or>"
'添加至选择集中,在选择过程中进行过滤
sset.SelectOnScreen FilterType, FilterData
MsgBox "sset.Count=" & sset.Count
还没有进行选择就直接弹出信息窗口 sset.Count=0
-------------------------------------------------------------------------------------------------------------------
然后我在论坛上寻找有关selectonscreen的问题,按照一个帖子的说法对过滤器进行了如下的修改,但是还是不能再cad绘图界面上对图元进行选择,请问这是什么问题呢?
Dim FilterType(0 To 3) As Integer
Dim FilterData(0 To 3) As Variant
FilterType(0) = 0
FilterData(0) = "*PolyLine"
Private Sub CommandButton1_Click()
Dim sset As AcadSelectionSet
On Error Resume Next
ThisDrawing.SelectionSets("dxd").Delete
Set sset = ThisDrawing.SelectionSets.Add("dxd")
On Error GoTo 0
Dim FilterType(0 To 3) As Integer
Dim FilterData(0 To 3) As Variant
'设置过滤器类型
FilterType(0) = -4
FilterType(1) = 0
FilterType(2) = 0
FilterType(3) = -4
'设置过滤数据
FilterData(0) = "<or"
FilterData(1) = "LWPolyline"
FilterData(2) = "line"
FilterData(3) = "or>"
Me.hide
'添加至选择集中,在选择过程中进行过滤
sset.SelectOnScreen FilterType, FilterData
MsgBox "sset.Count=" & sset.Count
Me.Show
End Sub
在我这边调试没有出现楼主的问题,很正常的 sscylh 发表于 2012-10-24 23:44 static/image/common/back.gif
在我这边调试没有出现楼主的问题,很正常的
我自己解决了
好像是窗体应该hide,我没有把命令放对位置,谢谢喽~ wylong 发表于 2012-10-24 22:50 static/image/common/back.gif
Me是窗体名称么?我后来自己解决的方法是吧Me.Hide放在了定义选择集之前,然后就实现了,我也不太懂为啥了~
页:
[1]