Jump to content

multiple drawing xref bind lisp


philk

Recommended Posts

Could anyone help me!

 

i'm looking for a lisp that can open, bind xrefs, purge, audit, save and close a drawing.

 

Maybe i'm being lazy, but i need to do this to a 100ish drawings.

 

Regards

 

Phil

Link to comment
Share on other sites

  • Replies 131
  • Created
  • Last Reply

Top Posters In This Topic

  • erik_NL

    24

  • JeepMaster

    18

  • rkohan

    12

  • Lee Mac

    10

Guest LElkins

Phil,

 

I have a vba which will bind all xrefs of drawings in the same directory as the current drawing. This doesn't deal with purge, audit, etc. although I should be able to ammend this to suit, but will not be able to right away, possibly for tomorrow or over the weekend.

 

Alternatively, I have a script that you can run using a batch file that will do all that you have asked for, again, only for drawings in that directory and will only perform a qsave and not a saveas.

 

Let me know which would be best.

 

Cheers

Link to comment
Share on other sites

Guest LElkins

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

Link to comment
Share on other sites

Neat routine, something I can use definitely. I was wondering whether the qsave could be replaced by saveas into another directory of choice, but then realised I can also copy all the sheet files into another directory and run this routine.

 

Thanks LElkins.

 

Guite

 

Edit: Just tested, works like a charm. Ehem, layers are locked and I checked back in the script.

Link to comment
Share on other sites

Guest LElkins
Ehem, layers are locked and I checked back in the script.

I don't quite follow Guite. Does that mean it is ok?

 

It should work fine if you follow the instructions I posted. If anyone has any problems then let me know.

 

It is possible to acheive this using Lisp or VBA, but by using a script file it means you can also use it with AutoCAD LT and not just full version.

 

Cheers

Link to comment
Share on other sites

Phil,

I have a vba which will bind all xrefs of drawings in the same directory as the current drawing. This doesn't deal with purge, audit, etc. although I should be able to ammend this to suit, but will not be able to right away, possibly for tomorrow or over the

Cheers

 

I wouldn't mind if you share the VBA Code, i'm more a VBA dude as a Lisp dude ;-)

 

TIA.

 

This should be a nice start to make a VBA to;

copy files to other dir, bind xref's to originals, zoom and purge originals, change some attributes etc in the ones that were copied. ( i'm working at a firm that's keeping drawings "as sent", so this is a day to day routine for me )

Link to comment
Share on other sites

I don't quite follow Guite. Does that mean it is ok?

 

It is OK. I ran the script on five sheet files. When I opened a sample file, I found all layers locked, was a bit surprised. Then I look at the script again and found that it is coded in. When doing manually, I never considered locking layers. I now see the benefit of it.

 

Guite

Link to comment
Share on other sites

Guest LElkins
I wouldn't mind if you share the VBA Code, i'm more a VBA dude as a Lisp dude ;-)

 

TIA.

 

This should be a nice start to make a VBA to;

copy files to other dir, bind xref's to originals, zoom and purge originals, change some attributes etc in the ones that were copied. ( i'm working at a firm that's keeping drawings "as sent", so this is a day to day routine for me )

 

erik,

 

I am just updating the vba code at the moment, trying to tidy it up a bit and ensure that it is relatively robust. I have already added the ability to save files into a specified directory and to zoom, purge, audit, lock layers. A few more tweaks to make but I will release it as soon as possible.

For now I suggest you utilise the script and bat I posted above.

 

Cheers

Link to comment
Share on other sites

erik,

 

I am just updating the vba code at the moment, trying to tidy it up a bit and ensure that it is relatively robust. I have already added the ability to save files into a specified directory and to zoom, purge, audit, lock layers. A few more tweaks to make but I will release it as soon as possible.

For now I suggest you utilise the script and bat I posted above.

 

Cheers

 

Sounds good to me. I don't need the script directly, projects for the moment aren't so big that it can't be done by hand. I can wait for you to publish your VBA Code.

 

Layer Lock is indeed a good idea, i hadn't thaught of that before. ( before i read about it in this thread )

 

again TIA.

Link to comment
Share on other sites

Guest LElkins

OK. The attached vba dvb performs tasks you may wish to perform when issuing drawings. Currently this is set to be for only the active drawing, although a little bit of work will allow for multiple files.

Using the interface, the user has the option to chose which routines will be performed. You can: -

Purge All

Audit

Zoom Extents

SaveAs or Overwrite Original

Bind Xrefs

Lock Layers

Lock Viewports

 

This is not particularly robust at the moment, and I have not tested it under every scenario. Let me know if you encounter any problems with it.

 

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

Guest LElkins

OK. Let me know if you come across any problems.

I am going to restructure it a bit and add some error handling, and make it for multiple files. What would the preferred method for selecting multiple files be? By browsing and selecting them, or by just working with all drawings in the same directory as the active drawing?

I will try and look at it over the weekend, but you know what it is like, valentines day next week, so whether I actually get a chance to look at it or not is a different matter. Will give it a shot though.

 

If anyone wants to adapt the code I posted then feel free, just please post back to let us all benefit from the modifications.

 

Cheers.

Link to comment
Share on other sites

Hi,

i'm @home, will take a look later on the evening and will let you know what i think about it.

If i have a say in it, selecting the drawings is the way to go ( not all my drawings in the directory have xref's to bind, there are some "schema's" ).

Link to comment
Share on other sites

Guest LElkins

The attached should now be working.

1 problem I have come across is if you have unloaded xrefs, so just detach first if you do not need them.

 

Cheers

Link to comment
Share on other sites

The attached should now be working.

1 problem I have come across is if you have unloaded xrefs, so just detach first if you do not need them.

 

Cheers

 

 

i'll test this one in stead of the 1st one. Actaully i've tested the 1st one very short and looked good. I set some of the buttons to true, that's some mouseclicks less ;-)

Link to comment
Share on other sites

Guest LElkins
I set some of the buttons to true, that's some mouseclicks less ;-)

 

Now that is just pure laziness.:lol:

Let me know if there is anything else that you can think of to change/add.

1 of my users requested the ability to print to pdf. I will not be adding that functionality as it goes against some of my core standards, but feel free to do it if you wish to. I am going to look at the possibility of creating dwf's, though that is dependant on pages setups being correct.

 

I am also looking at the possibility of exporting the drawing list to either a new or existing xls (for issue sheets) but not too sure about that yet.

 

Cheers

Cheers

Link to comment
Share on other sites

Now that is just pure laziness.:lol:

Let me know if there is anything else that you can think of to change/add.

1 of my users requested the ability to print to pdf. I will not be adding that functionality as it goes against some of my core standards, but feel free to do it if you wish to. I am going to look at the possibility of creating dwf's, though that is dependant on pages setups being correct.

 

I am also looking at the possibility of exporting the drawing list to either a new or existing xls (for issue sheets) but not too sure about that yet.

 

Cheers

Cheers

 

hmmm, making of pdf, i go to use the tool for "end of a status" for some drawings, clean, "archive" by binding the xrefs. Instead of making more files by making pdf's i want less and smaller files.

Off course it is easy to have a tool to make pdf's from all drawings but i didn't think it fits the profile of this tool.

Drawing lists, as far as we use them overhere, are maded in Excel but in a stadium before "prepare.dvb" using.

I also use SheetSet very much lately. There is a table making mechanisme for drawing lists.

 

For me this tool ( prepare ) is clearly for ending status "work", save, clean, etc etc and go on with "new" files in a other directory.

 

 

-- edit

 

tested version 2

NO problems found here, layers are locking, personally i would just remove not found xrefs' etc but i wait until you maked some multiple drawing version before i set some buttons to true ;-)

After you done that i'm going to try to edit the stamps in the "copied" drawings. But this one is very useful already !!

Link to comment
Share on other sites

Guest LElkins

I now have it working so you can select multiple files.

I am stuggling with sorting unloaded/unreferenced files. Anyone point me in the right direction to detach the references?

 

I will tweak it a bit either when I get home tonight or possibly tomorrow then upload it asap.

 

Nearly there now.

 

Cheers

Link to comment
Share on other sites

I went through that a while back and came up with this AWSOME lisp to Detach/Audit/bind/Purgeall. It can handle nested, unloaded, and unresolved xrefs. You MUST put a blank dwg named dummy.dwg in one of your search path folder for it to work.

 

See my thread here:

http://www.cadtutor.net/forum/showthread.php?t=13141

 

(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

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