Select 方法 (ActiveX) 
选择对象并将其放入选择集中,或选择表格中的单元格。 支持的平台:仅限 Windows 签名 - SelectionSetVBA: object.Select Mode [, Point1] [, Point2] [, FilterType, FilterData] 
 签名 - 表格VBA: object.Select wpt, wvwVec, wvwxvec, wxaper, wyaper, allowOutside, resultRowIndex, resultColumnIndex 
 返回值 (RetVal)无返回值。 备注 - SelectionSet此方法支持过滤机制。 提供以下选择模式: 
 有关更多选择模式选项,请参见 、 和 方法。SelectByPolygonSelectAtPointSelectOnScreen 备注 - 表格此函数通过指定点、查看方向和方向来选择表格中的单元格。所选单元格的行和列索引在 resultRowIndex 和 resultColumnIndex 中返回。 例子VBA: Sub Example_Select()
    ' This example adds members to a selection set, first by crossing and
    ' then by filtering for circles.
    
    ' Create the selection set
    Dim ssetObj As AcadSelectionSet
    Set ssetObj = ThisDrawing.SelectionSets.Add("SSET")
    
    ' Add all object to the selection set that lie within a crossing of (28,17,0) and
    ' (-3.3, -3.6,0) 
    Dim mode As Integer
    Dim corner1(0 To 2) As Double
    Dim corner2(0 To 2) As Double
    
    mode = acSelectionSetCrossing
    corner1(0) = 28: corner1(1) = 17: corner1(2) = 0
    corner2(0) = -3.3: corner2(1) = -3.6: corner2(2) = 0
    ssetObj.Select mode, corner1, corner2
    
    ' Add all the Circles to the selection set that lie within the crossing of (28,17,0) and
    ' (-3.3, -3.6,0) by filtering from the current drawing
    Dim gpCode(0) As Integer
    Dim dataValue(0) As Variant
    gpCode(0) = 0
    dataValue(0) = "Circle"
    
    Dim groupCode As Variant, dataCode As Variant
    groupCode = gpCode
    dataCode = dataValue
    
    ssetObj.Select mode, corner1, corner2, groupCode, dataCode
    
End Sub
可视化 LISP: (vl-load-com)
(defun c:Example_Select()
    ;; This example adds members to a selection set, first by crossing and
    ;; then by filtering for circles.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    ;; Create the selection set
    (setq ssetObj (vla-Add (vla-get-SelectionSets doc) "SSET"))
    
    ;; Add all object to the selection set that lie within a crossing of (28,17,0) and
    ;; (-3.3, -3.6,0)
    (setq mode acSelectionSetCrossing
          corner1 (vlax-3d-point 28 17 0)
          corner2 (vlax-3d-point -3.3 -3.6 0))
    (vla-Select ssetObj mode corner1 corner2)
    (alert (strcat "Objects selected: " (itoa (vla-get-Count ssetObj))))
    (vla-Clear ssetObj)
  
    ;; Add all the Circles to the selection set that lie within the crossing of (28,17,0) and
    ;; (-3.3, -3.6,0) by filtering from the current drawing
    (setq gpCode (vlax-make-safearray vlax-vbInteger '(0 . 0)))
    (vlax-safearray-put-element gpCode 0 0)
    (setq dataValue (vlax-make-safearray vlax-vbVariant '(0 . 0)))
    (vlax-safearray-put-element dataValue 0 "Circle")
    
    (vla-Select ssetObj mode corner1 corner2 gpCode dataValue)
    (alert (strcat "Objects selected: " (itoa (vla-get-Count ssetObj))))
    (vla-Delete ssetObj)
)
 | 
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1   苏公网安备32011402011833)
GMT+8, 2025-11-4 19:42
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.