|
发表于 2008-5-30 08:23:00
|
显示全部楼层
因为运行一次,选择集TEST_SSET已经存在,可以使用如下办法:
'创建过滤器的函数
Public Sub BuildFilter(TypeArray, dataArray, ParamArray gCodes())
Dim fType() As Integer, fData()
Dim index As Long, i As Long
index = LBound(gCodes) - 1
For i = LBound(gCodes) To UBound(gCodes) Step 2
index = index + 1
ReDim Preserve fType(0 To index)
ReDim Preserve fData(0 To index)
fType(index) = CInt(gCodes(i))
fData(index) = gCodes(i + 1)
Next
TypeArray = fType: dataArray = fData
End Sub
'创建空间选择集的函数
Public Function CreateSelectionSet(Optional ssName As String = "ss") As AcadSelectionSet
Dim ss As AcadSelectionSet
On Error Resume Next
Set ss = ThisDrawing.SelectionSets(ssName)
If Err Then Set ss = ThisDrawing.SelectionSets.Add(ssName)
ss.Clear
Set CreateSelectionSet = ss
End Function
'返回Thisdrawing,使用CreateSelectionSet和BuildFilter
'定义空白选择集
Dim LwPSelSet As AcadSelectionSet
Set LwPSelSet = CreateSelectionSet
'建立选择集过滤器
Dim TypeArray As Variant
Dim DateArray As Variant
BuildFilter TypeArray, DateArray, 0, "LWPOLYLINE", 8, "jmd"
'0 是类型 8是图层
LwPSelSet.SelectOnScreen TypeArray, DateArray ’其中TypeArray和DateArray是可选项 |
|