CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

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

2023-1-5 01:20| 发布者: admin| 查看: 654| 评论: 0|来自: AutoCAD

摘要: 要引用已知名称的现有选择集,请按名称引用该选择集。

要引用已知名称的现有选择集,请按名称引用该选择集。

以下示例引用名为“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-5-19 13:08

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部