Jump to content

DETACH Unreferenced Xref


MR MAN

Recommended Posts

Actually, my code does "Detach,Audit,bind,purge all". If you only want a code to detach unreferenced xrefs, removing audit and purge all is simple, but I don't know if removing the bind command is possible or not. Unless someone can modify the lisp so it will only bind "those unreferenced xrefs". That was the whole trick on this lisp, to repath the unreferenced xrefs to a blank drawing and bind the blank drawings.

**For this lisp to work, you MUST put a blank drawing named "dummy.dwg" in your search path.**

(defun C:SENT ( / )

 (defun *error*(msg)
   (setvar "modemacro" ".")
   (setvar "bindtype" oldBnType)
   (setvar "cmdecho" 1)
   (princ "\n...Audit/Bind/PurgeAll terminated!!!  ")
   (princ)
   ); end of *error*

 (setvar "modemacro" "Audit/Bind/PurgeAll processing......please wait......")
 (setvar "cmdecho" 0)
 (prompt "\n--- Audit/Bind/PurgeAll......please wait---")
 (prompt "\nAuditing...")(terpri)
 (command "_audit" "y")
 (bind_xrefs)
 (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--- Audit, Bind, PurgeAll completed! ---")
 (setvar "modemacro" ".")
 (setvar "cmdecho" 1)
 (princ)
); end of c:sent

(defun bind_xrefs ( / CMD)
 (setq oldBnType(getvar "bindtype"))
 (setq CMD (getvar "CMDECHO"))
 (setvar "CMDECHO" 0)
 (setvar "bindtype" 0)
 (setq XLIST (xref-status))
 (if XLIST 
   (progn
     (prompt "\nBinding all Xrefs...")
     (foreach n XLIST (rem-xref n))  
     (command "-xref" "b" "*" )
     (prompt "...done")(terpri)
   )  
 )
 (setvar "CMDECHO" CMD)
 (setvar "bindtype" oldBnType)
 (princ)
)

(defun rem-xref ( XL / XNAME XSTATUS )
 (setq XNAME (nth 0 XL))
 (setq XSTATUS (nth 2 XL))
 (if (= XSTATUS "UNLOADED")
   (rem_unload)
 )
 (if (= XSTATUS "UNRESOLVED")
   (rem_unload)
 )
)

(defun xref-status ( / d n f r)
 (while (setq d (tblnext "block" (null d)))
   (cond
     (
       (eq 4 (logand 4 (cdr (assoc 70 d))))
       (setq
         d (entget (tblobjname "block" (cdr (assoc 2 d))))
         n (cdr (assoc 2 d))
         p (cdr (assoc 3 d))
         f (cdr (assoc 70 d))
       )
       (setq r
         (cons
           (list n p
             (cond
               ( (eq 32 (logand 32 f)) "LOADED")
               ( (assoc 71 d) "UNLOADED")
               ( t "UNRESOLVED")
             )
           )
           r
         )
       )
     )
   )
 )
 (reverse r)
)


(defun rem_unload ( / )
 (setq DFILE (findfile "dummy.dwg"))
 (if (not DFILE)
   (prompt "\nCannot find dummy_xref drawing ")
   (progn
     (command "-xref" "p" XNAME DFILE)
     (command "-xref" "r" XNAME)
   )
 )
)

Link to comment
Share on other sites

  • 3 months later...

Your lisp code is really good.

How can I a loop to be able to use your code for an entire folder of drawings ( approximately 20-30 drawings).

 

E.q. : Select the folder and bind all the drawings automaticaly

 

Thanks for your answer

Link to comment
Share on other sites

How can I a loop to be able to use your code for an entire folder of drawings ( approximately 20-30 drawings).

You can use use ScriptPro (I prefer SuperScript better) and run the SENT command to all the dwgs. That's what I do when I need to bind a set of dwgs for clients.

Link to comment
Share on other sites

You can use use ScriptPro (I prefer SuperScript better) and run the SENT command to all the dwgs. That's what I do when I need to bind a set of dwgs for clients.

 

Thanks for your answer JeepMaster, unfortunately I can't install a software on my computer at work as I am not administrator.

 

Thanks

 

j3m

Link to comment
Share on other sites

Look at using a .bat file with a .scr file, in the script just run the lisp.

I have posted an example on here before, run a search and see if you can find it, in the mean time I will check my hard drives and see if I can find my templates.

Link to comment
Share on other sites

Thanks for your answer JeepMaster, unfortunately I can't install a software on my computer at work as I am not administrator.

j3m

You might already have scriptpro on your machine as it comes with AutoCAD if you have it checked during install. If not, you might still be able to download it from Autodesk and install, depending on what rights you have. I'm not an admin at work, but can still install scriptpro. Another option is getting SuperScript, it's a self contained exe program.

Link to comment
Share on other sites

  • 4 years later...

Hello JeepMaster, is there a way to modify the list to only BIND the unreferenced Xrefs, if not, how about not binding at all, the I have the option to manually detach the xref with the dummy drawing. Thanks

Link to comment
Share on other sites

  • 2 years later...
Hello JeepMaster, is there a way to modify the list to only BIND the unreferenced Xrefs, if not, how about not binding at all, the I have the option to manually detach the xref with the dummy drawing. Thanks

 

I modified JeepMaster's code so that the bind of all dwgs is commented out

      (foreach n XLIST (rem-xref n))  
;      (command "-xref" "b" "*" )
     (prompt "...done")(terpri)

and the bind is done as a part of the individual xref work.

(defun rem_unload ( / )
 (setq DFILE (findfile "dummy.dwg"))
 (if (not DFILE)
   (prompt "\nCannot find dummy_xref drawing ")
   (progn
     (command "-xref" "p" XNAME DFILE)
     (command "-xref" "r" XNAME)
     [color=red](command "-xref" "b" XNAME)[/color]
   )
 )
)

▲▼

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...