根据AutoCAD2004 VBA的说明,Select方法的描述为:
object.Select Mode[, Point1][, Point2][, FilterType][, FilterData]
如选择所有的圆,可以使用如下代码:
    Dim gpCode(0) As Integer
    Dim dataValue(0) As Variant
    gpCode(0) = 0
    dataValue(0) = "Circle"
    ssetObj.Select acSelectionSetAll, , , gpCode, dataValue
我的问题就是,如果要选择其它的对象,如何设置FilterType, FilterData?比如对象为
Ployline时。
哪位大侠能不能给一个关于此类设置的总结啊?
=============================
Mode
=============================
acSelectionSetWindow = 0 
Selects all objects completely inside a rectangular area whose corners are defined
by Point1 and Point2. And meets condition of FilterType and FilterData
 
acSelectionSetCrossing = 1
Selects objects within and crossing a rectangular area whose corners are defined by
Point1 and Point2.And meets condition of FilterType and FilterData
acSelectionSetFence = 2
Selects all objects completely inside Fence area whose are defined by Points. And
meets condition of FilterType and FilterData
acSelectionSetPrevious = 3
Selects the most recent selection set. This mode is ignored if you switch between
paper space and model space and attempt to use the selection set. And meets
condition of FilterType and FilterData
acSelectionSetLast = 4
Selects the most recently created visible objects. And meets condition of
FilterType and FilterData
acSelectionSetAll = 5
Selects all objects. And meets condition of FilterType and FilterData
acSelectionSetWindowPolygon = 6
acSelectionSetCrossingPolygon = 7
 
*****************************************************************************
参考:
'------------------------------------------------------------------
Option Explicit
'------------------------------------------------------------------
Public Sub Sample()
    On Error GoTo ERROR_HANDLER
    Dim ssetObj As AcadSelectionSet
    Set ssetObj = CreateSSet("MySelection")
   
    Dim mode As Integer
    mode = acSelectionSetAll
   
    Dim gpCode(0 To 10) As Integer
    Dim dataValue(0 To 10) As Variant
   
    gpCode(0) = -4
    dataValue(0) = "<Or"
    gpCode(1) = -4
    dataValue(1) = "<And"
    gpCode(2) = 0
    dataValue(2) = "LINE"
    gpCode(3) = -4
    dataValue(3) = "And>"
   
    gpCode(4) = -4
    dataValue(4) = "<And"
    gpCode(5) = 0
    dataValue(5) = "POLYLINE"
    gpCode(6) = -4
    dataValue(6) = "And>"
   
    gpCode(7) = -4
    dataValue(7) = "<And"
    gpCode(8) = 0
    dataValue(8) = "LWPOLYLINE"
    gpCode(9) = -4
    dataValue(9) = "And>"
   
    gpCode(10) = -4
    dataValue(10) = "Or>"
   
    Dim groupCode As Variant, dataCode As Variant
    groupCode = gpCode
    dataCode = dataValue
   
    ssetObj.Select mode, , , groupCode, dataCode
   
    MsgBox ssetObj.Count
   
    Exit Sub
ERROR_HANDLER:
    Debug.Print "Error In GetIntersectionPoints: " & Err.Number & ", " &
Err.Description
End Sub
'------------------------------------------------------------------
' 创建选择集
'------------------------------------------------------------------
Private Function CreateSSet(ByVal name As String) As AcadSelectionSet
    On Error GoTo ERR_HANDLER
   
    Dim ssetObj As AcadSelectionSet
filter过滤对象数组    Dim SSetColl As AcadSelectionSets
    Set SSetColl = ThisDrawing.SelectionSets
   
    Dim index As Integer
    Dim found As Boolean
   
    found = False
    For index = 0 To SSetColl.Count - 1
        Set ssetObj = SSetColl.Item(index)
        If StrComp(ssetObj.name, name, 1) = 0 Then
            found = True
            Exit For
        End If
    Next
   
   
    If Not (found) Then
        Set ssetObj = SSetColl.Add(name)
    Else
        ssetObj.Clear
    End If
   
    Set CreateSSet = ssetObj
   
    Exit Function
ERR_HANDLER:
    Debug.Print "Error in sub CreateSSet: " & Err.Number & " -- "; Err.Description
    Resume ERR_END
   
ERR_END:
End Function
***********************************************************************
过滤器列表由成对的参数组成。第一个参数标识过滤器的类型(例如对象),第二个参数指定
要过滤的值(例如圆)。过滤器类型是指定使用哪种过滤器的 DXF 组码。下面列出了一些最常
用的过滤器类型。
================================================================================
常用过滤器的 DXF 组码 <请详查DXF手册>
--------------------------------------------------------------------------------
DXF组码  过滤器类型                                          缺省值
--------------------------------------------------------------------------------

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。