请问在VBA中怎么使一个选择集只选中模型空间中可见图元?
请问在VBA中怎么使一个选择集只选中模型空间中可见图元?我隐藏&锁定&冻结了其他,然后使用了
FilterType = 60
FilterData = 0
sset.SelectOnScreen FilterType, FilterData
可是选不中任何图元,也没什么错误提示???
烦闷!
高手,救救我吧?
你必须通过图层过滤出可见的图层,然后把这些图层做为过滤器的条件
本帖最后由 mccad 于 2003-4-10 19:00:47 编辑Sub GetEnt()
Dim ss As AcadSelectionSet
Set ss = CreateSelectionSet
Dim Ly As String
Ly = ""
Dim Lyer As AcadLayer
Dim I As Integer
Debug.Print ThisDrawing.Layers.Count
For I = 0 To ThisDrawing.Layers.Count - 1
Set Lyer = ThisDrawing.Layers(I)
If Lyer.LayerOn = True Then
Ly = Ly & Lyer.Name & ","
End If
Next
Dim fType As Variant: Dim fData As Variant
BuildFilter fType, fData, 8, Ly
ss.Select acSelectionSetAll, , , fType, fData
Debug.Print ss.Count
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
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
页:
[1]