CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

计数属性 (ActiveX)

2023-1-3 19:50| 发布者: admin| 查看: 884| 评论: 0|来自: AutoCAD

摘要: 获取对象中的项数。

获取对象中的项数。

支持的平台:仅窗口

签名

工 务 局:

object.Count
对象

类型:所有集合字典材料部分管理器选择集

此属性适用的对象。

属性值

只读:是的

类型:整数

对象中的项数。

言论

没有额外的评论。

发布信息

释放:AutoCAD 2000 至 AutoCAD 2017

例子

工 务 局:

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

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

GMT+8, 2024-5-11 19:30

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部