In my efforts to learn more about modifying dwgs using ObjectDBX I came across this post: AttachExternalReference and ObjectDBX? (2 replies) Posted by: B, Jimmy Date: Sep/05/00 - 10:49 (EST) I am resposting because I could find no resolution to the problem. This is essentially the same code as was posted then, and the problem is still the same. That is the block insertion works but the xref ends up in the current dwg instead of the DBXdoc. Any help appreciated. Dean. Here is the code: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun C:test (/ doc objname) (setq dbxdoc (vla-GetInterfaceObject (vlax-get-acad-object) "ObjectDBX.AxDbDocument.16")) (setq filename "h:\z.dwg") (vla-open dbxdoc filename) (vla-insertblock (vla-get-modelspace dbxdoc) ;;(vla-get-paperspace doc) (list->variantArray '(0 0 0)) "h:\y.dwg" 1 1 1 0 ) (vla-AttachExternalReference (vla-get-modelspace dbxdoc) ;;(vla-get-paperspace doc) "h:\x.dwg" "x" (list->variantArray '(0 0 0)) 1 1 1 0 :vlax-false ) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-saveas (list dbxdoc filename))) (princ (strcat filename " Not saved!")) (princ (strcat filename " Saved!")) ) (vlax-release-object dbxdoc) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun list->variantArray (ptsList / arraySpace sArray) (setq arraySpace (vlax-make-safearray vlax-vbdouble (cons 0 (- (length ptsList) 1)))) (setq sArray (vlax-safearray-fill arraySpace ptsList)) (vlax-make-variant sArray) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;