I'm trying to add this function to my lisp. Currently my lisp does this Detach all unloaded xrefs/audit the dwg/bind dwg/ purge all. The problem I have here is when my dwg has nested xrefs, it will not bind. Can some help me out with a code that will do this:
If xref is nested and unloaded, then reload xref, and freeze all layers in xref.
Here's my code so far. I'm new to lisp.
Code:
(defun c:SENT (/ *error* oldBnType);
(defun *error*(msg)
(setvar "modemacro" ".")
(setvar "bindtype" oldBnType)
(setvar "cmdecho" 1)
(princ "\n...Detach/Audit/Bind/PurgeAll terminated!!! :( ")
(princ)
); end of *error*
(setq oldBnType(getvar "bindtype"))
(setvar "modemacro" "Detach/Audit/Bind/PurgeAll processing......please wait......")
(prompt "\n---Detach unloaded Xref, Audit, Bind, PurgeAll---")
(prompt "\nDetaching...")
(vlax-for block (vla-get-blocks
(vla-get-activedocument
(vlax-get-acad-object)))
(if (and (= :vlax-true (vla-get-isxref block))
(= 0 (vla-get-count block))
)
(vla-detach block)
)
)
(setvar "cmdecho" 0)
(prompt "...done")
(prompt "\nAuditing...")(terpri)
(command "_audit" "y")
(prompt "\nBinding all Xrefs...")
(setvar "bindtype" 0)
(command "-xref" "b" "*")
(prompt "...done")(terpri)
(prompt "\nPurging #1")(terpri)
(command "-purge" "a" "*" "N")
(prompt "\nPurging #2")(terpri)
(command "-purge" "a" "*" "N")
(prompt "\nPurging #3")(terpri)
(command "-purge" "a" "*" "N")
(prompt "\n---Detach, Audit, Bind, PurgeAll completed!---")
(setvar "modemacro" ".")
(setvar "cmdecho" 1)
(princ)
); end of c:sent