I am somewhat new to object orientated lisp or vlisp. I have a routine that have created to allow the user to select drawings and remove selected xrefs. It is presently using a script which I have never liked. So this an abbreviated version of the routine just for testing.
(setq acApp (vlax-get-acad-object))
(setq acDocs (vla-get-documents acApp))
(setq openfile(vla-open acDocs "C:\\TEST\\test052007.dwg"))
(vlax-for for-item (vla-get-Blocks openfile)
(if (and (= (strcase (vla-get-name for-item)) "MYXREF")
(= (vla-get-isxref for-item) ':vlax-true))
(setq current_xref for-item)))
(if current_xref (vla-detach current_xref))
if i am in the drawing it works fine. If I run it from another drawing, it opens the drawing then crashes with error: Automation Error. Description was not provided.
I suspect it is because the open drawing is not the active document. If anyone has a solution or better method it would be much appreciated.
The open drawing does not become the current document. Active document remains the document that the lisp was invoked from. If I run the lisp from the drawing it works fine. I am try to make a "batch routine' to remove specific xrefs from several drawings. I have a routine right now that allows to user to select drawings and it writes and runs a script.
If I (vlax-dump-object current_xref) it gives me all the information. It just won't let me vla-detach unless it is current drawing.
Is there away to either make the open document active or detach the remote documents xrefs?
I think I am have the same problem as How to use VLA-PUT-ACTIVEDOCUMENT
Limitations on Using AutoLISP in an MDI Environment
I found out how to make the open file active.
(vla-put-activedocument (vlax-get-acad-object) openfile)
However this opens the file and stalls altogether. Looks like I have to either sick with scripts or go with a .NET solution.
Will these work on a drawing that is not current or active? I can work in the current file it is opening a file and removing an xref then close and open another file an remove the xref. Before the MDI/SDI I was able to open, modify, and close drawing at will. (command ".OPEN" DRAWING COMMAND COMMAND...) basically an intelligent script. LISP was an amazingly power full tool back then.
Start with some of our most frequented solutions to get help installing your software.