CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

XefDatabase Property (ActiveX)

2023-1-3 00:57| 发布者: admin| 查看: 172| 评论: 0|来自: AutoCAD

摘要: 获取定义块内容的数据库对象。

获取定义块内容的数据库对象。

支持的平台:仅窗口

签名

工 务 局:

object.XRefDatabase
对象

类型:

此属性适用的对象。

属性值

只读:是的

类型:数据库

定义块内容的对象。Database

言论

仅当块的属性等于时,此属性才可用。IsXRefTrue

例子

工 务 局:

Sub Example_XRefDatabase()
    ' This example adds an external reference to the current drawing.
    ' It then cycles through each Block object in the drawing
    ' and determines the style of each Block by accessing the
    ' IsLayout and IsXRef properties of the Block. If the Block is an
    ' XRef Block, you obtain a reference to the external Database object
    ' for that Block and display the number of Blocks the Database contains.
    
    Dim InsertPoint(0 To 2) As Double
    Dim insertedBlock As AcadExternalReference
    Dim tempBlock As AcadBlock
    Dim msg As String, PathName As String
    
    ' Define external reference to be inserted
    InsertPoint(0) = 1: InsertPoint(1) = 1: InsertPoint(2) = 0
    PathName = "c:\program files\autocad\sample\city map.dwg"
    
    ' Add the external block to model space
    Set insertedBlock = ThisDrawing.ModelSpace.AttachExternalReference(PathName, "XREF_IMAGE", InsertPoint, 1, 1, 1, 0, False)
        
    ThisDrawing.Application.ZoomAll
    
    msg = vbCrLf & vbCrLf
    
    For Each tempBlock In ThisDrawing.Blocks
        If tempBlock.IsXRef Then
            ' Block is an external reference, so add it to list
            msg = msg & tempBlock.name & " contains " & _
            tempBlock.XRefDatabase.Blocks.count & " blocks"
            
            msg = msg & vbCrLf      ' Insert line
        End If
    Next
        
    ' Display Block information for the XRefDatabase
    MsgBox "Externally referenced blocks attached to this drawing have the following block counts: " & msg

End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_XRefDatabase()
    ;; This example adds an external reference to the current drawing.
    ;; It then cycles through each Block object in the drawing
    ;; and determines the style of each Block by accessing the
    ;; IsLayout and IsXRef properties of the Block. If the Block is an
    ;; XRef Block, you obtain a reference to the external Database object
    ;; for that Block and display the number of Blocks the Database contains.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Define external reference to be inserted
    (setq InsertPoint (vlax-3d-point 1 1 0)
          pathName (findfile ".\\Sample\\Sheet Sets\\Architectural\\Res\\STAIR1.dwg"))
    
    ;; Add the external block to model space
    (setq modelSpace (vla-get-ModelSpace doc))  
    (setq insertedBlock (vla-AttachExternalReference modelSpace pathName "XREF_IMAGE" InsertPoint 1 1 1 0 :vlax-false))
        
    (vla-ZoomAll acadObj)
    
    (setq msg "")
    (vlax-for tempBlock (vla-get-Blocks doc)
        (if (= (vla-get-IsXRef tempBlock) :vlax-true)
            (progn
                ;; Block is an external reference, so add it to list
                (setq msg (strcat msg (vla-get-Name tempBlock) " contains "
                                  (itoa (vla-get-Count (vla-get-Blocks (vla-get-XRefDatabase tempBlock)))) " blocks\n"))
            )
        )
    )
        
    ;; Display Block information for the XRefDatabase
    (alert (strcat "Externally referenced blocks attached to this drawing have the following block counts: " msg))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-12 19:45

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部