Gets the Database object that defines the contents of the block.
Supported platforms: Windows only
Read-only: Yes
Type: Database
The Database object that defines the contents of the block.
This property is only available if the IsXRef property for the block equals True.
VBA:
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)) )