ObjectDbx : Xref Detach kaput

Discussion in 'AutoCAD' started by Michael Puckett, Jan 11, 2005.

  1. I have not been able to successfully detach xrefs
    via ObjectDbx, yet the method is plainly exposed
    in the ObjectDbx object model.

    Can anyone else verify that the Detach method does
    not work via ObjectDbx?

    When I attempt to invoke the detach method it throws
    a descriptionless Automation error:

    "Automation Error. Description was not provided."

    My assumption is that despite the method being exposed
    it cannot be invoked because the ObjectDbx authors
    ran out of coffee.
     
    Michael Puckett, Jan 11, 2005
    #1
  2. Michael Puckett

    Owen Wengerd Guest

    Michael:
    I've used it successfully on the current working drawing. Make sure you
    delete any AcDbBlockReference objects that reference the xref block before
    you attempt to detach it. :)
     
    Owen Wengerd, Jan 11, 2005
    #2
  3. Thank you for responding Owen.

    I had tried to delete the actual instances but it had
    chucked a wobbly on that too. But I will try again just
    to double check.

    Just to be clear, I'm using ObjectDBX on documents that
    are _NOT_ active in the editor.

    Can you use ObjectDBX on documents already opened (like
    the active document)? In my experience ObjectDBX refuses
    to open documents already open. If I'm doing query only
    stuff I'll work off a temp copy, but otherwise one is hooped;
    again, this has been my experience this far.

    Thanks again Owen.

    Cheers.
     
    Michael Puckett, Jan 11, 2005
    #3
  4. I've read, in this newsgroup, that external references
    are not loaded in a drawing that is accessed via dbx.

    I suppose that if an xref hasn't been loaded then it can't
    be detached.
     
    Jason Piercey, Jan 11, 2005
    #4
  5. Michael Puckett

    Jeff Mishler Guest

    Michael, although it inherits a "Detach" method all you need do is delete
    all instances of the Xref's inserts and the next time the drawing is opened
    this displays:

    Opening an AutoCAD 2000 format file.

    Xref "Utils-Dec-04": C:\Land Projects 3\2004\24118 - Stony Village
    South\dwg\Utils-Dec-04.dwg
    "Utils-Dec-04" is unreferenced and has been purged.
    Regenerating model.

    Here's the code I tested with:
    Sub test_Xref_detach()
    Dim doc As AxDbDocument
    Dim obj As AcadEntity
    Dim xref As AcadExternalReference

    Set doc = GetInterfaceObject("ObjectDBX.AxDbDocument")
    doc.Open ("c:\test2000.dwg")
    For Each obj In doc.ModelSpace
    If TypeOf obj Is AcadExternalReference Then
    Set xref = obj
    xref.Delete
    End If
    Next
    doc.SaveAs ("c:\test2000.dwg")
    Set doc = Nothing
    End Sub
     
    Jeff Mishler, Jan 11, 2005
    #5
  6. Indeed.

    I don't know what was with my original attempt to
    delete the xref instances, but I was able to blow
    them away just now (my test model may have had locked
    layers, note to self: unlock / restore prior to mods).
    Subsequent opening of doc sported the purging messages
    you noted. A PurgeAll prior to saving may usurp said
    message. This works well enough for me.

    Thanks Jeff.

    (And Owen and Jason).
     
    Michael Puckett, Jan 11, 2005
    #6
  7. Note to self: PurgeAll not available in ObjectDBX.

    :)
     
    Michael Puckett, Jan 11, 2005
    #7
  8. Just a quick follow up / heads up note --

    If you are using the CleanRegApp.exe or
    CleanRegApp-2005.exe utilities (per thread 2004/12/09
    4:19PM -- "Fastest APP ID and layer filter purger
    available to everyone now!") to purge drawings with
    cancerous RegApp entries

    (see http://autodesk.blogs.com/between_the_lines/2004/12/layer_filter_an.html)

    AND

    you plan on Detaching XREFS via the 'Delete method as
    discussed in this thread ...

    .... hit the drawings with the CleanRegApp.exe first.

    If you delete the XREF instances and then try to use the
    CleanRegApp.exe utility it will go fatal (corrupting the
    drawing in the process). It's fine the other way round.

    <Based on nominal testing>
     
    Michael Puckett, Jan 11, 2005
    #8
  9. Michael Puckett

    Jeff Mishler Guest

    Very interesting.......thanks for being the guinea pig on that one ;-)
     
    Jeff Mishler, Jan 11, 2005
    #9
  10. Michael Puckett

    Rudy Tovar Guest

    Delete the object...

    Oh, and I had read in the Visual LISP Bible that you could open a document
    that was already opened by someone else, just that you couldn't open it if
    they were running the same dbx function you were, or something to that
    likeness...

    I've purged or should I say deleted layers, and blocks...using dbx...
     
    Rudy Tovar, Jan 11, 2005
    #10
  11. <musing out loud>

    Based purely on speculation / linear logic, there's
    a good chance said utilities will toss a wobbly when
    an xref entry exists without at least one instance,
    i.e. deleted by a user, not necessarily from code.
    While bad practice this happens. :(

    Maybe the util looks to an instance of an xref to find
    the path for the xref so if it can determine if said
    xref is responsible for some of the appids (this is
    frequently the case).

    Or not.

    Maybe it'll hurl ones and zeros on blocks defs without
    instances too.

    If I weren't so busy I'd check these scenarios out;
    perhaps down the road.

    </musing out loud>
     
    Michael Puckett, Jan 11, 2005
    #11
  12. Michael Puckett

    LUCAS Guest

    ;;Source is a valid path & dwg name
    ;;(DBX (getfiled "\ns\Select dwg file: " (getvar "dwgprefix") "dwg" 8))
    ;;By (LUCAS)
    ;;Code only work for one xref, not for nested xref....
    ;;Solution for nested xref¡K¡Kneed help!
    (defun DBX (SOURCE / APP ODOC DOC ODBX DOCTEST FILENAME)

    (vl-load-com)

    (setq APP (vlax-get-acad-object)
    DOC (vla-get-activedocument APP)
    )

    (vlax-for ODOC (vla-get-documents APP)
    (if (= (strcase (vla-get-fullname ODOC)) (strcase SOURCE))
    (setq DOCTEST t)
    )
    )

    (if (and (not DOCTEST) (setq FILENAME (findfile SOURCE)))
    (progn
    (if (> (atoi (getvar "AcadVer")) 15)
    (setq ODBX (vla-getinterfaceobject
    APP
    "ObjectDBX.AxDbDocument.16"
    )
    )
    (progn
    (if (not (vl-registry-read
    "HKEY_CLASSES_ROOT\\ObjectDBX.AxDbDocument\\CLSID"
    )
    )
    (startapp "regsvr32.exe"
    (strcat "/s \"" (findfile "axdb15.dll") "\"")
    )
    )
    (setq ODBX (vla-getinterfaceobject
    APP
    "ObjectDBX.AxDbDocument"
    )
    )
    )
    )
    (vla-open ODBX FILENAME)
    (TT ODBX)
    (DBXSAVE ODBX)
    (mapcar 'vlax-release-object (list APP DOC ODBX))
    )
    (progn
    (if DOCTEST
    (alert
    "You tried to use a file in use by Autocad, please close it and try
    again...."
    )
    (alert "Source file not found, please try again....")
    )
    )
    )
    (princ)
    )

    (defun DBXSAVE (DBXDOC)
    (vla-saveas DBXDOC (vla-get-name DBXDOC))
    )

    (defun TT (DOC / BLKS ENT NAME OLDNAME
    ENTT PATH ODBX1 LINETYPES OBJLIST
    X OBJARRAY
    )
    (setq BLKS (vla-get-blocks DOC))

    (vlax-for ENT BLKS
    (if (= (vla-get-isxref ENT) :vlax-true)
    (progn
    (setq PATH (vla-get-path ENT))
    (setq ODBX1 (vla-getinterfaceobject
    APP
    "ObjectDBX.AxDbDocument.16"
    )
    )
    (vla-open ODBX1 PATH)
    (setq LINETYPES (vla-get-linetypes ODBX1))
    ;;http://discussion.autodesk.com/thread.jspa?messageID=2043584
    ;;remove then linetypes error
    (vlax-for X LINETYPES
    (setq OBJLIST (cons X OBJLIST))
    )
    (setq OBJARRAY (vlax-safearray-fill
    (vlax-make-safearray
    vlax-vbobject
    (cons 0 (1- (length OBJLIST)))
    )
    OBJLIST
    )
    )
    (vlax-invoke-method
    ODBX1
    "copyobjects"
    OBJARRAY
    (vla-get-linetypes DOC)
    )
    (vlax-release-object LINETYPES)
    (vlax-release-object ODBX1)
    (vla-put-name
    ENT
    (setq OLDNAME (strcat (setq NAME (vla-get-name ENT)) "_LAI"))
    )
    (vla-delete
    (vla-insertblock
    (vla-get-modelspace DOC)
    (vlax-3d-point '(0 0 0))
    PATH
    1
    1
    1
    0
    )
    )
    )
    )
    )
    (vlax-for ENTT BLKS
    (vlax-for ENT ENTT
    (if (and (= (vla-get-objectname ENT) "AcDbBlockReference")
    (= (vla-get-name ENT) OLDNAME)
    )
    (vla-put-name ENT NAME)
    )
    (vla-update ENT)
    )
    )
    (vlax-release-object BLKS)
    (princ)
    )
     
    LUCAS, Jan 12, 2005
    #12
  13. That was the case in R15. When you accessed the Blocks
    collection, XRef blocks were not included (e.g., they were
    not in the collection at all).

    However, given that XREF operations were moved from
    the drawing editor to the databaase realm in R16, this
    probably has changed.

    I also don't know how this relates to VISRETAIN'd XREF
    layers, but since they are dependent on Xrefs, that might
    also need to be considered.
     
    Tony Tanzillo, Jan 12, 2005
    #13
  14. Thanks for the additional information.
     
    Jason Piercey, Jan 12, 2005
    #14
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.