Jump to content

multiple drawing xref bind lisp


philk

Recommended Posts

  • Replies 131
  • Created
  • Last Reply

Top Posters In This Topic

  • erik_NL

    24

  • JeepMaster

    18

  • rkohan

    12

  • Lee Mac

    10

so not sure why but one of the earlier lsp that jeepmaster posted that didn't always work in 2008 now always works in 2010 and the lsp that lee mac has always works in 2008.

Hmmm...interesting, I don't have 2010 so can't really test it. I guess when our company upgrade to 2010, then I'll need to go back to my old version of my SENT.lsp :D

Lee, do you know what's wrong with the newest version? Here's my current version that you helped rewrite.

;...............................................................................
;
;       << Detach unloaded/unresolved xrefs, Bind xrefs, Audit, Purge >>
;                              <<  July 2009 >>
;                              << Version 3.0 >>
;                     
;          NOTE: Must have a blank dwg in search path name "dummy.dwg" 
;
;...............................................................................


(defun c:sent (/ *error* doc xlst dfile lst OldBindType)
 (vl-load-com)

 (defun *error* (msg)
   (vla-EndUndoMark doc)
   (if (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
     (princ (strcat "\n<<< SENT Error: " msg " >>>"))
   )
   (setvar "modemacro" ".")
   (setvar "bindtype" OldBindType)
   (setvar "cmdecho" 1)
   (princ)
 ); end of *error*

 (setq doc (vla-get-ActiveDocument
             (vlax-get-acad-object)))
 (vla-StartUndoMark doc)
 (setvar "modemacro" "Audit/Bind/PurgeAll processing......please wait......")
 (setvar "cmdecho" 0)
 (setq OldBindType (getvar "bindtype"))
 (setvar "bindtype" 0)
 (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)))
           (setq lst
             (cons (strcat "\n<< XREF: " (car xref)" Failed to Bind >>") lst)
           )
       )
     )
     (princ "\n<< No XREFs Found >>")
   )
   (princ "\n<< Dummy File Not Found >>")
 )
 (terpri)
 (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")
 (prompt "\n--- Audit, Bind, PurgeAll completed! ---")
 (setvar "bindtype" OldBindType)
 (setvar "modemacro" ".")
 (if lst
   (mapcar 'princ (reverse lst)))
 (setvar "cmdecho" 1)
 (vla-EndUndoMark doc)
 (princ)
); end of sent


(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)
); end of xstatus


(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)
); end of x_bind

Wow, I didn't know this thread is this popular. Over 12000 views.

Link to comment
Share on other sites

hey guys,

 

if been doing a bit of tweaking on the lsp, i now have one that seems to work, on 2010 that even saves the file to a new folder, i'll post it up once i'v done a few tests on it.

Link to comment
Share on other sites

  • 1 month later...

hi jeep,

 

Hi i will post up the scr, lsp later, i have it running from a tool bar now and seems to work every time except for in DWG's that are missing an StmpFX.arx which was made by a 3rd party who are not making one for 2010.

Link to comment
Share on other sites

  • 2 weeks later...

I'm actually looking for help to improve my lisp so it will save the bound file to a new folder and not modify the current working file. I'm guessing it'll involve -checking and/or creating a new folder.

-saveas to new folder with current name.

Link to comment
Share on other sites

  • 9 months later...
Save the code below into a file called IssueRoutine.bat

Change C:\Program Files\AutoCAD Architecture 2008\acad.exe to the path of your acad exe.

Then place the IssueRoutine.bat into the same directory as the drawings. To run the routine double click on IssueRoutine.bat

Make sure that all instances of CAD are closed before you run the routine.

 

FOR %%V IN (*.DWG) DO START /W "c" "C:\Program Files\AutoCAD Architecture 2008\acad.exe" %%V /nologo /b "C:\IssueRoutine.scr"
FOR %%V IN (*.BAK) DO DEL %%V

 

Save the attached script file onto your C:\

 

Below is the contents of the script file.

 

-purge
all
*
n
audit
y
-xref
b
*
-purge
all
*
n
audit
y
-layer
lock
*
zoom
Extents
tilemode
0
mview
l
on
all
pspace
zoom
extents
qsave
quit

 

If you need any help or explanation of this then please ask.

 

Note that your machine will be unusable whilst the script is running, and although it may take a while to process 100 drawings, it is far quicker and less tedious than doing it manually.

 

Cheers

 

 

hello to LElkins,

 

i cant really quite get the process of running this script or changing the acad.exe path to my acad exe. I am using an autocad 2007 and 2009. Does this script work on both?

 

Please help me on this one.it would be a big help to me.Thanks

Link to comment
Share on other sites

  • 6 months later...

Jeepmaster - I tested the routine and I deleted some xrefs so they are unreferenced. Both your routine and Lee's version do not remove unrfererenced files from the drawings. Any suggestions? Thanks.

 

so not sure why but one of the earlier lsp that jeepmaster posted that didn't always work in 2008 now always works in 2010 and the lsp that lee mac has always works in 2008.

Hmmm...interesting, I don't have 2010 so can't really test it. I guess when our company upgrade to 2010, then I'll need to go back to my old version of my SENT.lsp :D

Lee, do you know what's wrong with the newest version? Here's my current version that you helped rewrite.

;...............................................................................

;

; >

; >

; >

;

; NOTE: Must have a blank dwg in search path name "dummy.dwg"

;

;...............................................................................

 

 

(defun c:sent (/ *error* doc xlst dfile lst OldBindType)

(vl-load-com)

Link to comment
Share on other sites

  • 3 months later...

just now saw your information on this vba. I know you removed the link since nobody appreciated your work. Is there anyway I can get a copy of the file. It looks like something I could really use to speed up our process on archiving files.

Thanks for your help.

 

 

 

Good Afternoon Ladies, Gentleman and children of all ages.

 

Sorry to keep bumping this and not letting the thread die, but I have now adjusted the vba, again, and it will now handle unloaded xrefs, and shouldn't (fingers crossed) throw any error messages.

The listbox will now have a horizontal scroll where necessary.

 

Extract the dvb file from the zip.

Place the dvb anywhere that you want, on the server if more users need it. Then create a custom button and add the macro

^C^C-vbarun;"dvb location/Prepare.dvb!Start";

where dvb location is the path to the dvb file. Ensure that you use / rather than \ in the file path.

 

Let me know if you have any problems.

 

Cheers

Link to comment
Share on other sites

  • 4 months later...

Hello LElkins,

 

Thank you very much for sharing such a nice tool. It really works perfectly, I used it in many projects. But it is not working for one specific set of drawing, when i use this tool it shows me this message "Cannot find the specified drawing file. Please verify that the file exists." Can you please guide me what should i have to do to solve this problem. (where i already purged & audit the drawing)

 

Thanks,

 

 

Asad

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...