获取对象中的项数。 支持的平台:仅窗口 属性值只读:是的 类型:整数 对象中的项数。 言论没有额外的评论。 例子工 务 局: 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))) ) ) |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-8 19:35
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.