ObjectDBX: vla-Detach
As Reference Manager can only change the path to External References, and not the name of the reference drawing itself (which I need to do), I'm looking into correcting a set of drawings using ObjectDBX.I've been successful at adding XREFs to ODBX drawings in the past using vla-AttachExternalReference, but am not understanding why I am receiving this error when attempting to detach:
; error: Automation Error. Description was not provided.
Here is my 'working' code at the moment:
(defun c:FOO(/ sheets path dbx n oXref) (vl-load-com) (if (and (setq sheets (vl-directory-files (setq path "SomePath\\") "*.dwg" 1)) (setq dbx (vla-GetInterfaceObject (vlax-Get-Acad-Object) (strcat "ObjectDBX.AxDbDocument." (substr (getvar 'acadver) 1 2))))) (progn (foreach sheetsheets (vl-catch-all-apply 'vla-open (list dbx (strcat path sheet))) (vlax-for x(setq oLayoutBlock (vla-get-block (vla-item (vla-get-layouts dbx) "Model"))) (if (and (= "AcDbBlockReference" (vla-get-objectname x)) (vl-position (setq n (vla-get-effectivename x)) '("XREF1" "XREF2")) (= :vlax-true (vla-get-isxref (setq oXref (vla-item (vla-get-blocks dbx) n))))) (vla-detach oXref))) ; I think you need to reference the document as the first parameter and then the xref as a second
(vla-detach dbx oXref) Soliver, I appreciate the suggestion.
Despite the parameters listed in the Developer Documentation, I tried your suggestion anyways with no success.
See the error returned:
; error: ActiveX Server returned the error: unknown name: Detach
... As the ODBX Document Object does not inherit the Detach Method.
Heavy
I think this post covers it: http://www.cadtutor.net/forum/archive/index.php/t-44133.html
I reckon the following is roughly what you're looking for from the link.
(vlax-for block (setq blocks(vla-get-blocks dbx))) (if(= (vla-get-isXRef block) :vlax-true) (vla-detach block) )) RenderMan,
Did you ever resolve this?
Knowing full well that I am willingly, officially zombifying this thread....
Wow I was bad about posting my solution back then... I did, and will dig through my toolbox to see if I cannot find what I used. I've learned a lot since back then, and may have changed code for other uses, etc..
Is there something specific your needing other than what I describe above? Of course, were I coding this new, I'd probably use the .NET API... Specifically ReadDwgFile() and Autodesk.AutoCAD.Internal.Utils.WcMatch(string, string) Methods. Specifically. Detaching an xref from a drawing that is opened with dbx.
I'm converting a lisp that originally only functioned in the current session. Now I wish to convert to batch processing with dbx.
I'm just not there in .net yet.
vla-detach works in the current session, but fails in dbx - exactly the problem you had. How did you wind up detaching while in dbx?
One suggestion was to vla-delete = failed
The post suggested by SOliver also did not solve. Couldn't really tell if Joro was getting results and Lee was trying to troubleshoot..??, or if Lee hadn't tested the concept first?? Either way, it was a similar issue. Lee's code generated the Automation error without vla-catch-all-apply.
I would have started a new post, but I didn't see that age of this post in my browser. Thanks for looking back into this. It was so long ago, I honestly do not remember how I got around this... I'll see what I can find, and post back. As far as I know, XRefs are not loaded in drawings opened with ObjectDBX and hence cannot be detached.
页:
[1]
2