AutoCAD 2004 VBA 又一个 BUG
下列例程来自AutoCAD 2004帮助文件,其中,最后一个语句为显示选择集对象个数而添加:Sub Example_Select()
' This example adds members to a selection set, first by crossing and
' then by filtering for circles.
' Create the selection set
Dim ssetObj As AcadSelectionSet
Set ssetObj = ThisDrawing.SelectionSets.Add("SSET")
' Add all object to the selection set that lie within a crossing of (28,17,0) and
' (-3.3, -3.6,0)
Dim mode As Integer
Dim corner1(0 To 2) As Double
Dim corner2(0 To 2) As Double
mode = acSelectionSetCrossing
corner1(0) = 28: corner1(1) = 17: corner1(2) = 0
corner2(0) = -3.3: corner2(1) = -3.6: corner2(2) = 0
ssetObj.Select mode, corner1, corner2
' Add all the Circles to the selection set that lie within the crossing of (28,17,0) and
' (-3.3, -3.6,0) by filtering from the current drawing
Dim gpCode(0) As Integer
Dim dataValue(0) As Variant
gpCode(0) = 0
dataValue(0) = "Circle"
Dim groupCode As Variant, dataCode As Variant
groupCode = gpCode
dataCode = dataValue
ssetObj.Select mode, corner1, corner2, groupCode, dataCode
Thisdrawing.Utility.Prompt ssetObj.Count
End Sub
在(28,17,0) 到 (-3.3, -3.6,0) 范围内,本来应该只有Circle会被选中,但实际上无论添加何种图元,均会被选中并计数,可见Select存有BUG!
不知道是我的AutoCAD 2004有问题,还是真的存在这个BUG!
AutoCAD 2004 VBA到底怎么了?
我准备改学LISP,DX们有何高见?请指教!谢谢! 是自己的程序有问题:
第一次ssetObj.Select mode, corner1, corner2。是将位于区域之内或者相交的所有对象都选中。
第二次ssetObj.Select mode, corner1, corner2, groupCode, dataCode。虽然这次只选择圆对象,但是第一选择时,选择集中的对象并没有清除掉。故它的选中实体的数目就是第一次选择时的数目。
应该在执行第二次时使用ssetObj.Clear先清除选择集。
页:
[1]