AttachExternalReference using DBX

Discussion in 'AutoCAD' started by dean_bourke, Feb 27, 2005.

  1. dean_bourke

    dean_bourke Guest

    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 "\tNot saved!"))
    (princ (strcat filename "\tSaved!"))
    )
    (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)
    )
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     
    dean_bourke, Feb 27, 2005
    #1
  2. dean_bourke

    Jeff Mishler Guest

    Add this to the list of "Things you can't do using ObjectDBX".......

    Known methods that won't work with ODBX:
    AttachExternalReference
    AuditInfo
    Purge
    Delete Layout
    Delete block of Layout
    Getvariable
    Setvariable
    Selection sets of any kind
    Save (use SaveAs)

    Will work but gives undesired result:
    Modify alignment type of an attributereference

    Properties that won't work:
    Anything that starts with Active.....
     
    Jeff Mishler, Feb 27, 2005
    #2
  3. dean_bourke

    dean_bourke Guest

    Thanks again Jeff.
    What about vla-Detach in the example below. I get a "Description was not provided"error.
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


    (defun c:xx (/)
    (setq dbxdoc (vla-GetInterfaceObject (vlax-get-acad-object) "ObjectDBX.AxDbDocument.16"))
    (setq filename "h:\\x.dwg")
    (vla-open dbxdoc filename)
    (vlax-for ENT (vla-get-blocks dbxDOC)
    (if (= (vla-get-isxref ENT) :vlax-true)
    (progn
    (print (vla-get-name ENT))
    (print(setq PATH (vla-get-path ENT)))
    (print ENT)
    (vla-Detach ent); description not provided
    )
    )
    )
    (vlax-release-object dbxdoc)
    )
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     
    dean_bourke, Feb 28, 2005
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.