兰州人 发表于 2009-8-29 17:27:00

选择集的and和or的应用.

这种组合,实现只在"AA1"图层中,找line实体.
fType(0) = -4: fData(0) = ""
Sub l()
Dim sSet As AcadSelectionSet
Dim fType(3) As Integer, fData(3) As Variant
Dim sSetName As String
sSetName = "First"
With ThisDrawing
      On Error Resume Next
      If Not IsNull(.SelectionSets.Item(sSetName)) Then
      Set sSet = .SelectionSets.Item(sSetName)
      sSet.Delete
      End If
      Set sSet = .SelectionSets.Add(sSetName)
    fType(0) = -4: fData(0) = ""
    sSet.Select 5, , , fType, fData
    sSet.Highlight True
    'Debug.Print sSet.Count
End With
End Sub
'''这种组合是图层aa1中的line和text实体
    fType(0) = -4: fData(0) = ""
    fType(3) = -4: fData(3) = "
Sub ls()
Dim sSet As AcadSelectionSet
Dim fType(6) As Integer, fData(6) As Variant
Dim sSetName As String
sSetName = "First"
With ThisDrawing
   
      On Error Resume Next
      If Not IsNull(.SelectionSets.Item(sSetName)) Then
      Set sSet = .SelectionSets.Item(sSetName)
      sSet.Delete
      End If
      Set sSet = .SelectionSets.Add(sSetName)
   
    fType(0) = -4: fData(0) = ""
    fType(3) = -4: fData(3) = ""
    sSet.Select 5, , , fType, fData
   
    Debug.Print sSet.Count
    sSet.Highlight True
   
End With
End Sub

雪山飞狐_lzh 发表于 2009-8-29 19:04:00

and在or内部才有用
选择集默认为and(与)
    fType(0) = -4: fData(0) = "
    fType(1) = 8: fData(1) = "标题栏"
    fType(2) = 0: fData(2) = "text"
   
    fType(3) = -4: fData(3) = "And>"
-》等效于
    fType(0) = 8: fData(0) = "标题栏"
    fType(1) = 0: fData(1) = "text"
   

雪山飞狐_lzh 发表于 2009-8-29 19:07:00

    fType(0) = -4: fData(0) = ""
    fType(3) = -4: fData(3) = ""
正确的写法:
8,"AA1",0,"Line,Text"

542392339 发表于 2010-1-6 17:28:00

谢谢啦

yg545france 发表于 2010-2-1 23:15:00

   fType(0) = -4: fData(0) = ""
必须得用运算符前后夹住图层AA1,是这个意思吗
页: [1]
查看完整版本: 选择集的and和or的应用.