CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2024 开发者帮助

Select 方法 (ActiveX)

2024-5-18 19:07| 发布者: admin| 查看: 11| 评论: 0|原作者: admin|来自: AutoCAD

Select 方法 (ActiveX)

选择对象并将其放入选择集中,或选择表格中的单元格。

支持的平台:仅限 Windows

签名 - SelectionSet

VBA:

object.Select Mode [, Point1] [, Point2] [, FilterType, FilterData]
对象

类型:SelectionSet

此方法应用到的对象。

模式

访问:仅输入

类型:枚举AcSelect

  • acSelectionSetWindow
  • acSelectionSetCrossing
  • acSelectionSetPrevious
  • acSelectionSetLast
  • acSelectionSetAll
第1点

访问:仅输入;自选

类型:变体(双打的三元素阵列)

指定 Point1 的 3D WCS 坐标或坐标数组。有关正确使用 Point1 的信息,请参阅模式定义。

第2点

访问:仅输入;自选

类型:变体(双打的三元素阵列)

指定 Point2 的 3D WCS 坐标。有关正确使用 Point2 的信息,请参阅模式定义。

筛选类型

访问:仅输入;自选

类型:变体

指定要使用的筛选器类型的 DXF 组代码。

筛选数据

访问:仅输入;自选

类型:变体

要筛选的值。

签名 - 表格

VBA:

object.Select wpt, wvwVec, wvwxvec, wxaper, wyaper, allowOutside, resultRowIndex, resultColumnIndex
对象

类型: 表格

此方法应用到的对象。

WPT技术

访问:仅输入

类型:变体

WCS 中的 3D 点指定输入拾取点。

wvwVec(英语:wvwVec)

访问:仅输入

类型:变体

WCS 中的 3D 矢量,用于指定命中测试的视图方向。

WVWXVEC系列

访问:仅输入

类型:变体

WCS 中的 3D 矢量,用于指定命中测试的视图方向。

WXAPER的

访问:仅输出

类型:

以命中点为中心的孔径框的宽度,用于命中测试;保留以备将来使用。

怀珀

访问:仅输出

类型:

以命中点为中心的孔径框高度,用于命中测试;保留以备将来使用。

允许外部

访问:仅输入

类型:布尔

  • True:表格外的拾取点将选择一个单元格。
  • False:表格外的拾取点不会选取单元格。
结果RowIndex

访问:仅输出

类型:

所选单元格的行索引。

结果列索引

访问:仅输出

类型:

所选单元格的列索引。

返回值 (RetVal)

无返回值。

备注 - SelectionSet

此方法支持过滤机制。

提供以下选择模式:

  • 窗:完全选取矩形区域内的所有对象,其角由 Point1Point2 定义。
  • 路口:选择矩形区域内和相交的对象,其角由 Point1Point2 定义。
  • 以前:选择最新的选择集。如果在图纸空间和模型空间之间切换并尝试使用选择集,则忽略此模式。
  • 最后:选择最近创建的可见对象。
  • 都:选择所有对象。

有关更多选择模式选项,请参见 、 和 方法。SelectByPolygonSelectAtPointSelectOnScreen

备注 - 表格

此函数通过指定点、查看方向和方向来选择表格中的单元格。所选单元格的行和列索引在 resultRowIndexresultColumnIndex 中返回。

例子

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)
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-6-27 16:20

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部