Bind Method (ActiveX)

Binds an external reference (xref) to a drawing.

Supported platforms: Windows only

Signature

VBA:

object.Bind bPrefixName
object

Type: Block

The object this method applies to.

bPrefixName

Access: Input-only

Type: Boolean

  • True: Symbol names are not prefixed.
  • False: Symbol names are prefixed with <blockname>$x$.

Return Value (RetVal)

No return value.

Remarks

Binding an xref to a drawing makes the xref a permanent part of the drawing and no longer an externally referenced file. The externally referenced information becomes a block. When the externally referenced drawing is updated, the bound xref is not updated. This method binds the entire drawing's database, including all of its dependent symbols. Dependent symbols are named objects such as blocks, dimension styles, layers, linetypes, and text styles. Binding the xref allows named objects from the xref to be used in the current drawing.

If the bPrefixName parameter is set to False, the symbol names of the xref drawing are prefixed in the current drawing with <blockname>$x$, where x is an integer that is automatically incremented to avoid overriding existing block definitions. If the bPrefixName parameter is set to True, the symbol names of the xref drawing are merged into the current drawing without the prefix. If duplicate names exist, AutoCAD uses the symbols already defined in the local drawing. If you are unsure whether your drawing contains duplicate symbol names, it is recommended that you set bPrefixName to False.

Examples

VBA:

Sub Example_Bind()
    On Error GoTo ERRORHANDLER
                          
    ' Define external reference to be inserted
    Dim xrefHome As AcadBlock
    Dim xrefInserted As AcadExternalReference
    Dim insertionPnt(0 To 2) As Double
    Dim PathName As String
    insertionPnt(0) = 1
    insertionPnt(1) = 1
    insertionPnt(2) = 0
    PathName = "c:/AutoCAD/sample/City map.dwg"
    
    ' Add the external reference
    Set xrefInserted = ThisDrawing.ModelSpace. _
            AttachExternalReference(PathName, "XREF_IMAGE", _
            insertionPnt, 1, 1, 1, 0, False)
    ZoomAll
    MsgBox "The external reference is attached."
    
    ' Bind the external reference definition
    ThisDrawing.Blocks.Item(xrefInserted.name).Bind False
    MsgBox "The external reference is bound."
    Exit Sub
ERRORHANDLER:
    MsgBox Err.Description
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_Bind()
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
                          
    ;; Define external reference to be inserted
    (setq insertionPnt (vlax-3d-point 1 1 0)
          pathName (findfile ".\\Sample\\Sheet Sets\\Architectural\\Res\\STAIR1.dwg"))

    ;; Add the external reference
    (setq modelSpace (vla-get-ModelSpace doc))  
    (setq xrefInserted (vla-AttachExternalReference modelSpace pathName "XREF_IMAGE" insertionPnt 1 1 1 0 :vlax-false))
    (vla-ZoomAll acadObj)
    (alert "The external reference is attached.")
    
    ;; Bind the external reference definition
    (vla-Bind (vla-Item (vla-get-Blocks doc) (vla-get-Name xrefInserted)) :vlax-false)
    (alert "The external reference is bound.")
)