erik_NL Posted February 29, 2008 Posted February 29, 2008 and it will run on multiple files? No, not that i know. Quote
rkohan Posted February 29, 2008 Posted February 29, 2008 So is there a routine that will remove any unloaded/unused xrefs and bind drawings in bulk? I personally did not work on any of the drawings but it is my job to transmit them to the client. If I have to open every drawing to check for unused xrefs, I might as well bind them at the same time. Quote
Guest LElkins Posted February 29, 2008 Posted February 29, 2008 So is there a routine that will remove any unloaded/unused xrefs and bind drawings in bulk? I personally did not work on any of the drawings but it is my job to transmit them to the client. If I have to open every drawing to check for unused xrefs, I might as well bind them at the same time. YES. As I have said before, my final vba post will acheive this. PM me with your email add and I will send it to you. Cheers Quote
JeepMaster Posted February 29, 2008 Posted February 29, 2008 and it will run on multiple files? You don't use the lisp to run in "bulk", but you use ScriptPro(or similar) to run this command to all your drawings. That's the whole point of using this command. If you use ScriptPro, load all your dwgs then run the command: SENT QSAVE That's all you need. I run this everytime I need to sent stuff to clients. I personally use SuperScript because it's a lot faster. You should have ScriptPro installed, it came with AutoCAD. If you don't have it, you can download it from Autodesk website. I run batch scripts all the time, especially if you need to run a command to 80+ dwgs at a time. Imagine opening 80+ dwgs and freezing a few layers then save and close the dwgs everyweek. I'd kill myself if I have to do this manually. Quote
uthay Posted March 14, 2008 Posted March 14, 2008 Hi LElkins i couldn't find the link to download your vba program zip. please post the link again , thanks Quote
cadmaker Posted May 21, 2008 Posted May 21, 2008 LElkins, I have a project that needs to bind a thousand plus drawings and save them to a new directory. It sounds like your code would put me well on the way to accomplish this. I did not see the code available on the forum. Can you send a copy of it to byron@cadmaker.com? It would be greatly appreciated. Thanks LElkins. YES. As I have said before, my final vba post will acheive this. PM me with your email add and I will send it to you. Cheers Quote
LCE Posted May 21, 2008 Posted May 21, 2008 cadmaker, When do you need this for? Do you just need to bind the drawings, or do everything else that the app does. I ask as I am currently re-writing it into VB.NET which is making it more robust and allowing more options. Let me know. Cheers Quote
LCE Posted May 21, 2008 Posted May 21, 2008 Hi LElkins i couldn't find the link to download your vba program zip. please post the link again , thanks uthay, Sorry that I missed this post. Please see my above post. I endeavour to upload this routine converted to VB.NET by the end of the week, there are no promises of this though. If you require this asap then let me know and I will up the VBA, else, keep your eyes open for me posting the VB.NET app. Quote
cadmaker Posted July 16, 2008 Posted July 16, 2008 Good day to you in the UK. I see that my reply was not listed to your question, so I will try again. We do still have the need for a bind routine. It is not critical at the moment but remains in the background all the time. Our goal as I see it is to take a list of files that are created from a number of XREFs. This could be over a few directories. These files need to stay where they are in the XREF type. I want to be able to update the files where they are to be sure they have the most recent XREFs and then make a copy of those updated files in annother directory. I then want to bind those copied files to make them freindly to the outside world. These files will ultimately be accessible via the web. We would run this as needed or on a schedule to be sure all updates were implemented and ready to post on the web site. I don't think we need all of the other functionality you had. On the forums I have not been able to find where the VBA code is. I would love to see what code you have for similar tasks that we might be able to use or tweek to accomplish our goals. Any help here would be greatly appreciated. My address was listed a few posts up. Thanks again. Byron - CADMaker cadmaker,When do you need this for? Do you just need to bind the drawings, or do everything else that the app does. I ask as I am currently re-writing it into VB dot NET which is making it more robust and allowing more options. Let me know. Cheers Quote
jfurlong Posted April 14, 2009 Posted April 14, 2009 Jeep master First thanks for the lsp. I have used your lsp and I have to say most times it works, but sometimes I find it doesn't. What I have to do is open the xref -purge all * n save then the xref will bind. So what I'm asking is - is it possible to add to your lsp or even write a lsp (maybe someone already has one. I can't find one) that will open all the xref's in a dwg and purge them. Quote
JeepMaster Posted June 17, 2009 Posted June 17, 2009 Jeep master First thanks for the lsp. I have used your lsp and I have to say most times it works, but sometimes I find it doesn't. What I have to do is open the xref -purge all * n save then the xref will bind. So what I'm asking is - is it possible to add to your lsp or even write a lsp (maybe someone already has one. I can't find one) that will open all the xref's in a dwg and purge them. jfurlong, You can try the code below to see if it works for all your drawings. I've added an extra purgeall code before binding drawings. I've ran into problems for binding certain drawings in the pass if I purge my drawings before binding, that's why I did the purge code in the end. But if this one works better for you, then more power to you. ;............................................................................... ; ; << Detach unloaded/unresolved xrefs, Bind xrefs, Audit, Purge >> ; << June 2009 >> ; << Version 2.2.1 >> ; ; NOTE: Must have a blank dwg in search path name "dummy.dwg" ; ;............................................................................... (defun C:SENT ( / ) (defun *error*(msg) (setvar "bindtype" oldBnType) (setvar "cmdecho" 1) (princ "\n...undoing SENT...") (command "_undo" "E") (command "_undo" "1") (command "regenall")(terpri) (princ "\n...SENT Undone!...Audit/Bind/PurgeAll terminated!!! ") (setvar "modemacro" ".") (princ) ); end of *error* (command "_undo" "BE") (setvar "modemacro" "Audit/Bind/PurgeAll processing......please wait......") (setvar "cmdecho" 0) (prompt "\n--- Audit/Bind/PurgeAll......please wait---") (prompt "\nAuditing...")(terpri) (command "_audit" "y") (command "-purge" "a" "*" "N") (bind_xrefs) (prompt "\nPurging RegApps")(terpri) (command "-purge" "R" "*" "N") (prompt "\nPurging #1")(terpri) (command "-purge" "a" "*" "N") (prompt "\nPurging #2")(terpri) (command "-purge" "a" "*" "N") (prompt "\nPurging #3")(terpri) (command "-purge" "a" "*" "N") (command "_undo" "E")(terpri) (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) ) ) ) Quote
Lee Mac Posted June 21, 2009 Posted June 21, 2009 Can I use the *.scr code as a macro? Do you mean you want to run the script from a toolbar button? Quote
Lee Mac Posted June 21, 2009 Posted June 21, 2009 JeepMaster, As I say, I haven't got much experience working with XRefs, but I tried to re-write your LISP to help you out. Let me know if it works... [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:sent [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] *error* doc xlst dfile[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] *error* [b][color=RED]([/color][/b]msg[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-EndUndoMark[/color][/b] doc[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]wcmatch[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcase[/color][/b] msg[b][color=RED])[/color][/b] [b][color=#ff00ff]"*BREAK,*CANCEL*,*EXIT*"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#ff00ff]"\n<< Error: "[/color][/b] msg [b][color=#ff00ff]" >>"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#ff00ff]"\n*Cancel*"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] doc [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveDocument[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-StartUndoMark[/color][/b] doc[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-AuditInfo[/color][/b] doc [b][color=Blue]:vlax-true[/color][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] dfile [b][color=RED]([/color][/b][b][color=BLUE]findfile[/color][/b] [b][color=#ff00ff]"dummy.dwg"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] xlst [b][color=RED]([/color][/b]xstatus[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]foreach[/color][/b] xref xlst [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] [b][color=RED]([/color][/b]x_reload [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] xref[b][color=RED])[/color][/b] dfile [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] xref[b][color=RED])[/color][/b] [b][color=BLUE]t[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#ff00ff]"\n<< XREF: "[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] xref[b][color=RED])[/color][/b][b][color=#ff00ff]" Failed to Bind >>"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#ff00ff]"\n<< No XREFs Found >>"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#ff00ff]"\n<< Dummy File Not Found >>"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-PurgeAll[/color][/b] doc[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-EndUndoMark[/color][/b] doc[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] xstatus [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] tdef elst flag xlst[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]while[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] tdef [b][color=RED]([/color][/b][b][color=BLUE]tblnext[/color][/b] [b][color=#ff00ff]"BLOCK"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] tdef[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cond[/color][/b] [b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] [b][color=#009900]4[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]logand[/color][/b] [b][color=#009900]4[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]70[/color][/b] tdef[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] elst [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]tblobjname[/color][/b] [b][color=#ff00ff]"BLOCK"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]2[/color][/b] tdef[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] flag [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]70[/color][/b] elst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] xlst [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]2[/color][/b] elst[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cond[/color][/b] [b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] [b][color=#009900]32[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]logand[/color][/b] [b][color=#009900]32[/color][/b] flag[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=BLUE]nil[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]71[/color][/b] elst[b][color=RED])[/color][/b] [b][color=BLUE]t[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]t[/color][/b] [b][color=BLUE]t[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] xlst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]reverse[/color][/b] xlst[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] x_bind [b][color=RED]([/color][/b]xNme file flag [b][color=BLUE]/[/color][/b] xref[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] blk [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Blocks[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveDocument[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-catch-all-error-p[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-catch-all-apply[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]function[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]lambda[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] xref[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] xref [b][color=RED]([/color][/b][b][color=BLUE]vla-item[/color][/b] blk xNme[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] flag [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-put-path[/color][/b] xref file[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-reload[/color][/b] xref[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-Bind[/color][/b] xref [b][color=Blue]:vlax-false[/color][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=BLUE]t[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] Quote
asos2000 Posted July 8, 2009 Posted July 8, 2009 LEE what is it mean > and how is this lisp deal with unloaded Xrefs Quote
JeepMaster Posted July 8, 2009 Posted July 8, 2009 LeeMac, I couldn't get your version of my bind lisp to work. But don't worry about it as mine works just fine for me, and I understand it perfectly and I can modify to suit any of my future needs. Whereas yours, I have no idea what's going on due to my limited coding skills. Oh well. Quote
Lee Mac Posted July 8, 2009 Posted July 8, 2009 LEE what is it mean > and how is this lisp deal with unloaded Xrefs Sorry, typo - my fault: (defun c:sent (/ *error* doc xlst dfile) (vl-load-com) (defun *error* (msg) (vla-EndUndoMark doc) (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")) (princ (strcat "\n<< Error: " msg " >>")) (princ "\n*Cancel*")) (princ)) (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) (vla-StartUndoMark doc) (vla-AuditInfo doc :vlax-true) (if (setq dfile (findfile "dummy.dwg")) (if (setq xlst (xstatus)) (foreach xref xlst (if (not (x_bind (car xref) dfile (if (cdr xref) t))) (princ (strcat "\n<< XREF: " (car xref)" Failed to Bind >>")))) (princ "\n<< No XREFs Found >>")) (princ "\n<< Dummy File Not Found >>")) (vla-PurgeAll doc) (vla-EndUndoMark doc) (princ)) (defun xstatus (/ tdef elst flag xlst) (while (setq tdef (tblnext "BLOCK" (not tdef))) (cond ((eq 4 (logand 4 (cdr (assoc 70 tdef)))) (setq elst (entget (tblobjname "BLOCK" (cdr (assoc 2 tdef)))) flag (cdr (assoc 70 elst))) (setq xlst (cons (cons (cdr (assoc 2 elst)) (cond ((eq 32 (logand 32 flag)) nil) ((assoc 71 elst) t) (t t))) xlst))))) (reverse xlst)) (defun x_bind (xNme file flag / xref) (setq blk (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object)))) (if (not (vl-catch-all-error-p (vl-catch-all-apply (function (lambda (/ xref) (setq xref (vla-item blk xNme)) (if flag (progn (vla-put-path xref file) (vla-reload xref))) (vla-Bind xref :vlax-false)))))) t)) Quote
JeepMaster Posted July 8, 2009 Posted July 8, 2009 Thanks LeeMac, Your lisp seems to work great. It even report back the problem xrefs...Cool! Now only if I know what all those code means. Quote
JeepMaster Posted July 8, 2009 Posted July 8, 2009 LeeMac, It doesn't seem like the purgeall command is running. I still have to endup doing a purge all to purge everything out. Also, where would I add command if I need to add come custom commands in. Let say I need to add a lisp command (command "PAA") Would it be just before the (vla-EndUndoMark doc) line? Quote
Recommended Posts
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.