CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2018 开发者帮助

Count 属性 (ActiveX)

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

Count 属性 (ActiveX)

获取对象中的项数。

支持的平台:仅限 Windows

签名

VBA:

object.Count
对象

类型:所有集合字典材料SectionManagerSelectionSet

此属性应用于的对象。

属性值

只读:是的

类型:整数

对象中的项数。

言论

没有其他评论。

发行信息

释放:AutoCAD 2000 到 AutoCAD 2017

例子

VBA:

Sub Example_Count()
    ' Use count to retrieve the number of objects in a collection
    ' You might use this value in a loop structure to iterate through the collection
    
    MsgBox "There are " & ThisDrawing.Layers.Count & " layer(s) in the drawing."
    MsgBox "There are " & ThisDrawing.ModelSpace.Count & " object(s) in ModelSpace."

    Dim objCount As Integer
    Dim I As Integer
    objCount = ThisDrawing.ModelSpace.Count
    
    Dim mspaceObj As AcadObject
    For I = 0 To objCount - 1
        Set mspaceObj = ThisDrawing.modelSpace.Item(I)
        MsgBox "The objects in ModelSpace include: " & mspaceObj.ObjectName, vbInformation, "Count Example"
    Next
    
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_Count()
    ;; Use count to retrieve the number of objects in a collection
    ;; You might use this value in a loop structure to iterate through the collection
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    (alert (strcat "There are " (itoa (vla-get-Count (vla-get-Layers doc))) " layer(s) in the drawing."))
    (alert (strcat "There are " (itoa (vla-get-Count (vla-get-ModelSpace doc))) " object(s) in ModelSpace."))

    (setq I 0
	  objCount (vla-get-Count (vla-get-ModelSpace doc)))
    
    (while (>= (- objCount 1) I)
        (setq mspaceObj (vla-Item (vla-get-ModelSpace doc) I)
	      I (1+ I))
        (alert (strcat "The objects in ModelSpace include: " (vla-get-ObjectName mspaceObj)))
    )
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2025-3-14 05:55

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部