listing1
Public Sub trigerSUB(layerName As String, Optional asPoint As Boolean = True)
Dim objSelSet As AcadSelectionSet
Dim objEnt As AcadEntity
Dim intType1(0 To 6) As Integer
Dim varData1(0 To 6) As Variant
If asPoint Then
intType1(0) = -4: varData1(0) = "<AND"
intType1(1) = -4: varData1(1) = "<OR"
intType1(2) = 0: varData1(2) = ""
intType1(3) = 0: varData1(3) = "POINT"
intType1(4) = -4: varData1(4) = "OR>"
intType1(5) = 8: varData1(5) = layerName
intType1(6) = -4: varData1(6) = "AND>"
Else
intType1(0) = -4: varData1(0) = "<AND"
intType1(1) = -4: varData1(1) = "<OR"
intType1(2) = 0: varData1(2) = "LWPOLYLINE"
intType1(3) = 0: varData1(3) = "POLYLINE"
intType1(4) = -4: varData1(4) = "OR>"
intType1(5) = 8: varData1(5) = layerName
intType1(6) = -4: varData1(6) = "AND>"
End If
Set objSelSet = SmatrSel(intType1, varData1)
[b]'подсчет селектированных объектов[/b]
summa = summa + objSelSet.Count
End Sub
Public Function SmatrSel(ByRef filtData() As Integer, varData As Variant) As AcadSelectionSet
Dim objSelSet As AcadSelectionSet
Dim objSelCol As AcadSelectionSets
Set objSelCol = ThisDrawing.SelectionSets
For Each objSelSet In objSelCol
If objSelSet.Name = "Test_Sel" Then
objSelSet.Delete
Exit For
End If
Next
Set objSelSet = objSelCol.Add("Test_Sel")
Dim objEnt As AcadEntity
objSelSet.Select acSelectionSetAll, , , filtData, varData
Set SmatrSel = objSelSet
End Function
listing2
Public Sub CountOBJ()
Dim Entt As String
summa = 0
Dim ent As AcadEntity
On Error Resume Next
For Each ent In ThisDrawing.ModelSpace
Select Case ent.ObjectName
Case "AcDbPoint"
[b]'подсчет объектов[/b]
summa = summa + 1
Case "AcDb3dPolyline"
[b]'подсчет объектов[/b]
summa = summa + 1
Case "AcDbPolyline"
[b]'подсчет объектов[/b]
summa = summa + 1
Case Else
MsgBox ent.ObjectName
End Select
Next ent
MsgBox summa
End Sub
данные алгоритмы дают разную сумму селектированных элементов listing2, показывает правильно. Помогите разобраться в чем проблема