CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2023 开发者帮助

Blocks 属性 (ActiveX)

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

Blocks 属性 (ActiveX)

获取图形的 Blocks 集合。

支持的平台:仅限 Windows

签名

VBA:

object.Blocks
对象

类型:数据库文档

此属性应用于的对象。

属性值

只读:是的

类型:积木

绘图的集合。Blocks

言论

没有其他评论。

例子

VBA:

Sub Example_Blocks()
    ' This example first finds the Blocks collection
    ' using the Blocks property. It then adds a new
    ' block to the Blocks collection.
    
    Dim blkColl As AcadBlocks
    Dim newBlock As AcadBlock
    Dim insertionPnt(0 To 2) As Double
    
    ' Get the Blocks collection
    Set blkColl = ThisDrawing.Blocks
    
    ' Define the insertion point for the new block
    insertionPnt(0) = 0#: insertionPnt(1) = 0#: insertionPnt(2) = 0#
    
    ' Add the new block into the Blocks collection
    Set newBlock = blkColl.Add(insertionPnt, "TEST")
    MsgBox "A block called " & newBlock.name & " has been added to the blocks collection", vbInformation, "Blocks Example"
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_Blocks()
    ;; This example first finds the Blocks collection
    ;; using the Blocks property. It then adds a new
    ;; block to the Blocks collection.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    ;; Get the Blocks collection
    (setq blkColl (vla-get-Blocks doc))
    
    ;; Define the insertion point for the new block
    (setq insertionPnt (vlax-3d-point 0 0 0))
    
    ;; Add the new block into the Blocks collection
    (setq newBlock (vla-Add blkColl insertionPnt "TEST"))
    (alert (strcat "A block called " (vla-get-Name newBlock) " has been added to the blocks collection."))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-12-15 11:56

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部