- 积分
- 73549
- 明经币
- 个
- 注册时间
- 2001-6-7
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2003-4-10 19:00:00
|
显示全部楼层
你必须通过图层过滤出可见的图层,然后把这些图层做为过滤器的条件
本帖最后由 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 |
|