CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2022 开发者帮助

关于显示有关选择集的信息 (VBA/ActiveX)

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

关于显示有关选择集的信息 (VBA/ActiveX)

若要引用您知道其名称的现有选择集,请按名称引用它。

以下示例引用名为“SS10:”的选择集

Sub GetObjInSet()
  Dim selset As AcadSelectionSet
  Set selset = ThisDrawing.SelectionSets("SS10")

  MsgBox ("Selection set " & selset.Name & " contains " & _
    selset.Count & " items")
End Sub

图形中的每个选择集都是集合的成员。可以使用该语句循环访问图形的集合并收集有关每个选择集的信息。SelectionSetsFor EachSelectionSets

显示图形中每个选区集的名称

下面的代码显示图形中每个选择集的名称,并列出每个选择集中包含的对象类型:

Sub ListSelectionSets()
  Dim selsetCollection As AcadSelectionSets
  Dim selset As AcadSelectionSet
  Dim ent As Object
  Dim i, j As Integer

  Set selsetCollection = ThisDrawing.SelectionSets

  ' Find each selection set in the drawing
  i = 0
  For Each selset In selsetCollection
    MsgBox "Selection set " & CStr(i) & " is: " & selset.Name

    ' Now find each object in the selection set, and say what it is
    j = 0
    For Each ent In selset
       MsgBox "Item " & CStr(j + 1) & " in " & selset.Name _ 
         & "is: " & ent.EntityName
       j = j + 1
    Next
    i = i + 1
  Next
End Sub

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

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

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部