PDA

View Full Version : multiple drawing xref bind lisp



philk
7th Feb 2008, 10:13 am
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

LElkins
7th Feb 2008, 11:37 am
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

LElkins
7th Feb 2008, 12:34 pm
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

Guite
7th Feb 2008, 02:08 pm
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.

LElkins
7th Feb 2008, 02:40 pm
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

erik_NL
7th Feb 2008, 06:30 pm
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 )

Guite
7th Feb 2008, 06:55 pm
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

LElkins
8th Feb 2008, 11:03 am
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

erik_NL
8th Feb 2008, 11:36 am
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.

LElkins
8th Feb 2008, 02:27 pm
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

erik_NL
8th Feb 2008, 02:38 pm
OK. The attached vba dvb

Cheers


Nice, i'm going to play with it @home. Some folding to do and then to home.

Thanks.

LElkins
8th Feb 2008, 02:41 pm
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.

LElkins
8th Feb 2008, 03:20 pm
Just realised I screwed up the lock layers.
I will have another run through with it and repost later.
Sorry.

Cheers

erik_NL
8th Feb 2008, 04:29 pm
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" ).

LElkins
8th Feb 2008, 04:48 pm
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

erik_NL
8th Feb 2008, 05:03 pm
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 ;-)

LElkins
8th Feb 2008, 05:11 pm
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

erik_NL
8th Feb 2008, 05:33 pm
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 !!

LElkins
8th Feb 2008, 06:41 pm
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

JeepMaster
8th Feb 2008, 08:19 pm
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)
)
)
)

erik_NL
9th Feb 2008, 07:55 pm
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


I could be wrong here, but aren't just running the xref binding just 3 times ? Or am i overlooking something ?

JeepMaster
11th Feb 2008, 04:19 pm
I could be wrong here, but aren't just running the xref binding just 3 times ? Or am i overlooking something ?
I don't quite understand your question. My lisp audits the dwgs, binds them all, then purge the drawings 3 times.

erik_NL
11th Feb 2008, 04:21 pm
I don't quite understand your question. My lisp audits the dwgs, binds them all, then purge the drawings 3 times.

that's indeed my question. euhm, i mean if the drawing has 4 xref's, one will not be binded ?

-- edit --
Nevermind, i wasn't looking as well as i should have.

LElkins
12th Feb 2008, 10:52 am
Good Morning Ladies and Gents

I now have it so it will allow for multiple drawing select.

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/AutoArchive.dvb!Start";
where dvb location is the path to the dvb file. Ensure that you use / rather than \ in the file path.

Ensure that all unloaded/unreferenced xrefs are removed prior to using this tool.
When saveas it will create a directory named as YYMMDD in the selected directory.
Ensure that you have closed all drawing, and just start a new drawing when running the tool.
Your AutoCAD session will not be unusable for a short period of time, which will differ dependant on the number and size of drawings that you have selected. This time should be minimal.


Let me know if you have any problems or make any modifications.

If anyone would like a detailed description of how to use it then please PM with your email add and I will forward an email.

Cheers

Please note that the attach vba script is provided as is, and you use at your own risk. Although it has been tested thoroughly, it is impractical to test each possible scenario.

erik_NL
13th Feb 2008, 10:47 am
[quote=LElkins;127003]Good Morning Ladies and Gents

I now have it so it will allow for multiple drawing select.
quote]

LElkins,

some short testing done, time ain't on my side these week. Getting a error on the viewport locking part.

testingmethod; Did a qnew drawing, run the program, selected the options. Debug said error in the bold line;


If VpLockBtn.Value = True Then
Dim vp As AcadEntity
For Each vp In ThisDrawing.PaperSpace
If vp.ObjectName = "AcDbViewport" Then
vp.DisplayLocked = True
End If
Next
End If

LElkins
13th Feb 2008, 10:50 am
OK. Did the previous single drawing version work ok?
Is there a VP in the new drawing paperspace?

Cheers

erik_NL
13th Feb 2008, 12:24 pm
Yes, there is a viewport in the drawing. Looks like it ain't depending on the viewport routine ( again quick testing ) but at the end of the routine ( the complete routine ).
I just did a real life test with the viewport option NOT selected and after all the drawings were done there was a error. Hope you can do something with this info.

LElkins
13th Feb 2008, 12:29 pm
I will look into it. I have been running it now for a few days and have been testing it on various systems and i working fine.

Will let you know when I come up with a fix.

Cheers

LElkins
13th Feb 2008, 12:30 pm
Out of curiosity, did you select one of the save options, either to saveas or overwrite the original?

Cheers

erik_NL
13th Feb 2008, 12:33 pm
Out of curiosity, did you select one of the save options, either to saveas or overwrite the original?

Cheers

Yes,
I did "overwrite the original".
can do some more testing after the break :)

-- Edit --
By selecting multiple drawings,
I can only select one drawing at the time, isn't there a solution to select all in dir or just as in Explorer with shift and/or ctrl.

karencheirifs
15th Feb 2008, 06:45 pm
If you need any help or explanation of this then please ask.

Cheers

Hi! LElkins, Ive succesfully used the script to bind files you where so kind to post... :)
The problem is, that the script is not binding all of my files. Ive checked those files and they dont seem to have any problem in the xrefs, since Ive tried to do the binding manually with the "-xref" and "b" commands and it works perfectly. Do you have any idea why this could be happenning?
Any help would be really apreciated.

LElkins
15th Feb 2008, 06:46 pm
I will have a look this weekend if I get a chance.

Cheers

erik_NL
15th Feb 2008, 08:03 pm
I will have a look this weekend if I get a chance.

Cheers

FYI, i'm running acad2008 and have no problems. Maybe something to look for ?

karencheirifs
16th Feb 2008, 12:39 am
Tried in acad 2008 using the same files , but they didnt work either...

karencheirifs
18th Feb 2008, 08:47 pm
Hi, i havent been succesful w my problem... im sending you the script file since i had to make some changes to it, because i was getting an error... (basically just not locking the VP) but the thing is, it works in some of the files but only on like one out of ten...
It is opening all the files and it appears to be doing everything on the script but then i open it and the references are there. Sometimes the size of the file changes so i guess it did purge, but not the bind...

I have never used a dvb so im sticking w ths script for now...i hope you could help me out...
Thanks a lot!

Im copying the text of the cript im using here:



-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

LElkins
19th Feb 2008, 10:13 am
Hi, i havent been succesful w my problem... im sending you the script file since i had to make some changes to it, because i was getting an error... (basically just not locking the VP) but the thing is, it works in some of the files but only on like one out of ten...
It is opening all the files and it appears to be doing everything on the script but then i open it and the references are there. Sometimes the size of the file changes so i guess it did purge, but not the bind...


Sorry Karen, I had assumed you were referring to the dvb.
When using this script, ensure that you have no unreferenced external references, or unloaded external references, as this will throw an error and it will skip the remaining xrefs. The reason it is not locking the viewport is because I had added the lock layers before lock viewports. See the updated attached script and let me know how things go.

Thank you.

LElkins
19th Feb 2008, 10:15 am
ArchiveRoutine.zip (http://www.cadtutor.net/forum/attachment.php?attachmentid=4538&d=1202809657) (24.0 KB, 6 views)

6 views, but only 1 person comments? Anyone else?
I am still working with it to try and improve it, but if anyone else can add some input or advise, that would be great.

Thank you.

Have a great day all.

erik_NL
19th Feb 2008, 08:10 pm
ArchiveRoutine.zip (http://www.cadtutor.net/forum/attachment.php?attachmentid=4538&d=1202809657) (24.0 KB, 6 views)

6 views, but only 1 person comments? Anyone else?
I am still working with it to try and improve it, but if anyone else can add some input or advise, that would be great.

Thank you.

Have a great day all.

will try to take a dive into it. But first some excersises from the course i toke. AutoCAD Customizing :-)

Edit -
I think this lisp is to much for me for a quick look. I'm going to look further in the VBA as posted as that's the language i want to learn.

JeepMaster
20th Feb 2008, 04:37 pm
Hi, i havent been succesful w my problem... im sending you the script file since i had to make some changes to it, because i was getting an error... (basically just not locking the VP) but the thing is, it works in some of the files but only on like one out of ten...
It is opening all the files and it appears to be doing everything on the script but then i open it and the references are there. Sometimes the size of the file changes so i guess it did purge, but not the bind...

I have never used a dvb so im sticking w ths script for now...i hope you could help me out...
Thanks a lot!

Im copying the text of the cript im using here:



-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
My lisp code is somewhat similar to your script and you can easily modify it to your needs. It has more error traps and it can handle unloaded/unreference/unresolved xrefs. Here's the code again:
(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)
)
)
)
If you need help using lisp, just let me know. You need to put a blank dwg named "dummy.dwg" in your search path. See page 2 Post #20.

LElkins
20th Feb 2008, 05:35 pm
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

LElkins
22nd Feb 2008, 10:17 am
So 8 views so far, and still no comments?
Any problems? Any changes needed?

Cheers

erik_NL
22nd Feb 2008, 10:25 am
So 8 views so far, and still no comments?
Any problems? Any changes needed?

Cheers

Did find some problems, i'm writing them on paper for now and try to post them later this morning when i "found them all".

LElkins
22nd Feb 2008, 10:28 am
Did find some problems, i'm writing them on paper for now and try to post them later this morning when i "found them all".

Cheers. Please do as I am curious what they are, all working fine my end for about 30 users...

erik_NL
22nd Feb 2008, 10:59 am
ok,
The one i could reproduce easy;
Starting a fresh autocad session. By running the tool ( with vbarun under a macro ), getting the select drawings form, i selected 3 locally drawings with one xref each. select on the secondscreen all but "save as". It opens the drawings but it looks as it is on the last; i'm getting the following error;

Runtime Error '-2145320900 (8021003c)
Failed to get the document object

Debug marks the next line
Count = ThisDrawing.Blocks.Count - 1

still running acad2008

LElkins
22nd Feb 2008, 11:08 am
ok,
The one i could reproduce easy;
Starting a fresh autocad session. By running the tool ( with vbarun under a macro ), getting the select drawings form, i selected 3 locally drawings with one xref each. select on the secondscreen all but "save as". It opens the drawings but it looks as it is on the last; i'm getting the following error;

Runtime Error '-2145320900 (8021003c)
Failed to get the document object

Debug marks the next line
Count = ThisDrawing.Blocks.Count - 1

still running acad2008

Cheers,

I have just had a look, and eventually managed to reproduce this error, and as untidy as it may be, if you add the line

On Error Resume Next
above

Count = ThisDrawing.Blocks.Count - 1

then it should be fine.

Try it out and let me know.

Cheers

erik_NL
22nd Feb 2008, 12:03 pm
Cheers,

I have just had a look, and eventually managed to reproduce this error, and as untidy as it may be, if you add the line

above


then it should be fine.

Try it out and let me know.

Cheers

First check did give the same error, i copied some more line's of the same on all subs with the line "next" after the dim lines.

Checked again and it all is ok !!!!!!
Thanks !

erik_NL
24th Feb 2008, 10:59 am
First check did give the same error, i copied some more line's of the same on all subs with the line "next" after the dim lines.

Checked again and it all is ok !!!!!!
Thanks !

Quoting myself :-)
I have problems downloading the file ( i'm @ home and didn't bring the file with me ). Am i the only one having this problem ?

LElkins
24th Feb 2008, 11:33 pm
Quoting myself :-)
I have problems downloading the file ( i'm @ home and didn't bring the file with me ). Am i the only one having this problem ?

Having problems d/ling?
You mean because you can't see a link or what?
This is probably because I deleted the attachment as I felt advantage was being taken of my work without any kind of thanks, input or anything. I have noticed this happens a lot on the site, and feel that some of the guys need to take a good long think about the time some people spend on here helping others, with very little gratitude in most cases. One short message of thanks, or a bit of input, be it constructive critisicm, or other, is often all it takes, but for there to be nothing, it often leaves you questioning yourself for as to why you bother.

erik, this does not apply to you. You have been very grateful and very helpful, thank you. I am more than happy to email you updated versions of this when required.

Cheers

erik_NL
25th Feb 2008, 12:07 am
Having problems d/ling?
You mean because you can't see a link or what?
This is probably because I deleted the attachment as I felt advantage was being taken of my work without any kind of thanks, input or anything. I have noticed this happens a lot on the site, and feel that some of the guys need to take a good long think about the time some people spend on here helping others, with very little gratitude in most cases. One short message of thanks, or a bit of input, be it constructive critisicm, or other, is often all it takes, but for there to be nothing, it often leaves you questioning yourself for as to why you bother.

erik, this does not apply to you. You have been very grateful and very helpful, thank you. I am more than happy to email you updated versions of this when required.

Cheers

Thank you for the kind words. I'm trying to learn from the people here. I've the file @ work so no problem for me.

Hope you still will try to help people here. I'm learning from you and others here fast but i'm still no vba expert and not everything is in the book(s) ;-)

saiman
26th Feb 2008, 09:14 pm
Anyone know how I can detach an unloaded Xref(s) in the multiple bind routine?

LElkins
27th Feb 2008, 10:06 am
Anyone know how I can detach an unloaded Xref(s) in the multiple bind routine?

Saiman,

Which routine are you referring to? Script? VBA? Lisp?
This was handled automatically in the final file VBA I posted. If you do not have that then let me know.

I am currently reviewing the possibility of handling nested xrefs, although I am not sure which route I will take yet, if any.

Cheers

Timmy007
27th Feb 2008, 12:28 pm
Hi!

Im trying to run the script on the 1st page... i have followed the instructions (i think) and run the script, but it says "can't find the dwg. check the file exists"


Any ideas on what i'm doing wrong?

cheers

Timmy

saiman
27th Feb 2008, 02:42 pm
LElkins (http://www.cadtutor.net/forum/member.php?u=9689),
I am using your IssueRoutine.scr, it works great but some xrefs will not bind due to unloaded xref's. I want to be able to detach the unloaded xrefs in the dwgs if possible.

Also, do you have anything that will flatten 3D objects/blocks? I've used the flatten command, burst, explode, export, etc. but, sometimes that still doesn't work. I was wondering if anyone have something better to convert 3D into 2D.

Thanks for your Help:D

LElkins
27th Feb 2008, 03:05 pm
LElkins (http://www.cadtutor.net/forum/member.php?u=9689),
I am using your IssueRoutine.scr, it works great but some xrefs will not bind due to unloaded xref's. I want to be able to detach the unloaded xrefs in the dwgs if possible.


Saiman,
As far as I can see, this doesn't seem to be possible. I suggest you look at vba or lisp if you have full version of autocad.



Also, do you have anything that will flatten 3D objects/blocks? I've used the flatten command, burst, explode, export, etc. but, sometimes that still doesn't work. I was wondering if anyone have something better to convert 3D into 2D.


I have a few things that may acheive what you want. I don't have them at work with me. I will see if I can find them at home when I get a chance.

Cheers

JeepMaster
27th Feb 2008, 04:02 pm
Anyone know how I can detach an unloaded Xref(s) in the multiple bind routine?
My lisp could! See page 2

saiman
27th Feb 2008, 04:09 pm
JeepMaster (http://www.cadtutor.net/forum/member.php?u=1504)
awesome! thanks a bunch:D

LElkins
27th Feb 2008, 04:14 pm
JeepMaster (http://www.cadtutor.net/forum/member.php?u=1504)
awesome! thanks a bunch:D
Saiman,

Out of curiosity, why were you using the .scr rather than the vba that I posted. The .scr is purely a cheap and cheerful way to acheive a similar result in LT...

Cheers

saiman
27th Feb 2008, 04:56 pm
LElkins (http://www.cadtutor.net/forum/member.php?u=9689)
I do like the vba better and It looks awesome.I would love to use it, but it doesn't let you select multiple dwgs and it gives me a "runtime error '-2145320900(8021003c): fail to get the Document object".

You are the man!:D

erik_NL
27th Feb 2008, 07:12 pm
LElkins (http://www.cadtutor.net/forum/member.php?u=9689)
I do like the vba better and It looks awesome.I would love to use it, but it doesn't let you select multiple dwgs and it gives me a "runtime error '-2145320900(8021003c): fail to get the Document object".

You are the man!:D

i can't remember my error exactly but if this is the some error i had; check this thread pls. Look for; Resume on error.

rkohan
28th Feb 2008, 05:07 pm
Just so you know, I am a new/casual user. I tried the process, but when it opened the first file it stopped. It is just sitting there. Am I missing something?

LElkins
28th Feb 2008, 05:15 pm
Just so you know, I am a new/casual user. I tried the process, but when it opened the first file it stopped. It is just sitting there. Am I missing something?

hi rkohan,

Can you please be a bit more specific as to which routine you are using. The .scr file? the vba?

Cheers

rkohan
28th Feb 2008, 05:19 pm
I am using the .scr. Seems like it would do what I needed. I tried it again and it opens the file, refreshes the screen with everything lightened up, then sits there until I push the close "X" in the right hand corner and moves to the next file.

It doesn't seem like it is doing anything. Again, please excuse my ignorance, we just switched over from MicroStation 3 months ago.

LElkins
28th Feb 2008, 05:27 pm
OK. I assume then that you are running it using the .bat file that was with the .scr? Have you ammended this at all?

Cheers

rkohan
28th Feb 2008, 05:33 pm
Just what was in the original post. Changed to our acad.exe path.

saiman
28th Feb 2008, 05:47 pm
rkohan,
check your script file to see if you hit enter after quit:D happen to me too, forgot to add it:oops:

erik_NL
any word on the Flatten command?:D

erik_NL
28th Feb 2008, 05:57 pm
erik_NL
any word on the Flatten command?:D

it's flat ????

rkohan
28th Feb 2008, 05:58 pm
I tried adding the enter to the .scr after quit, but it still stops at a lightened version of the file.

I copied what was typed in an pated it below. Any ideas?



Customization file loaded successfully. Customization Group: ACAD
Customization file loaded successfully. Customization Group: CUSTOM
Customization file loaded successfully. Customization Group: VAULT
Customization file loaded successfully. Customization Group: EXPRESS
Opening an AutoCAD 2007 format file.
Resolve Xref "2051bdr": O:\51205100\Borders\2051bdr.dwg
"2051bdr" loaded.
Resolve Xref "2051amf2": O:\51205100\Arch\2051amf2.dwg
"2051amf2" loaded.
Xref "XXXXbdr": O:\New Project Template\Borders\XXXXbdr.dwg
"XXXXbdr" is unreferenced and has been purged.
Regenerating layout.
Regenerating model.
AutoCAD Express Tools Copyright © 2002-2004 Autodesk, Inc.
AutoCAD menu utilities loaded.
Autodesk DWG. This file is a TrustedDWG last saved by an Autodesk application
or Autodesk licensed application.
Command: -purge
Enter type of unused objects to purge
[Blocks/Dimstyles/LAyers/LTypes/MAterials/Plotstyles/SHapes/textSTyles/Mlinestyl
es/Tablestyles/Visualstyles/Regapps/All]: all
Enter name(s) to purge <*>: *
Verify each name to be purged? [Yes/No] <Y>: n
No unreferenced blocks found.
No unreferenced layers found.
No unreferenced linetypes found.
No unreferenced text styles found.
No unreferenced shape files found.
No unreferenced dimension styles found.
No unreferenced mlinestyles found.
Deleting plotstyle "Solid".
1 plotstyle deleted.
No unreferenced table styles found.
No unreferenced materials found.
No unreferenced visual styles found.
Enter BACKSPACE to interrupt script.
Command: audit
Fix any errors detected? [Yes/No] <N>: y
Auditing Header
Auditing Tables
Auditing Entities Pass 1
Pass 1 1300 objects audited
Auditing Entities Pass 2
Pass 2 1300 objects audited
Auditing Blocks
225 Blocks audited
Total errors found 0 fixed 0
Erased 0 objects
Command: -xref
Enter an option [?/Bind/Detach/Path/Unload/Reload/Overlay/Attach] <Attach>: b
Enter xref name(s) to bind: *
Regenerating layout.
Regenerating model.
Command: -purge
Enter type of unused objects to purge
[Blocks/Dimstyles/LAyers/LTypes/MAterials/Plotstyles/SHapes/textSTyles/Mlinestyl
es/Tablestyles/Visualstyles/Regapps/All]: all
Enter name(s) to purge <*>: *
Verify each name to be purged? [Yes/No] <Y>: n
No unreferenced blocks found.
No unreferenced layers found.
No unreferenced linetypes found.
No unreferenced text styles found.
No unreferenced shape files found.
No unreferenced dimension styles found.
No unreferenced mlinestyles found.
No unreferenced plotstyles found.
No unreferenced table styles found.
No unreferenced materials found.
No unreferenced visual styles found.
Command: audit
Fix any errors detected? [Yes/No] <N>: y
Auditing Header
Auditing Tables
Auditing Entities Pass 1
Pass 1 2100 objects audited
Auditing Entities Pass 2
Pass 2 2100 objects audited
Auditing Blocks
225 Blocks audited
Total errors found 0 fixed 0
Erased 0 objects
Command: -layer
Current layer: "Symb"
Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck/Unlock
/stAte]: lock
Enter name list of layer(s) to lock or <select objects>: *
Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck/Unlock
/stAte]: zoom
Invalid option keyword.
Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck/Unlock
/stAte]: *Cancel*

saiman
28th Feb 2008, 06:03 pm
converting 3d to 2d.:D

rkohan
28th Feb 2008, 06:07 pm
Huh?

I'm lost. Remember, I',m new. In Microstation V* there is a command that does all of this. AutoCAD is a foreign language for me that I am just learning.

Sorry

saiman
28th Feb 2008, 06:08 pm
try adding (enter) before the zoom:D

[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck/Unlock
/stAte]: ((enter))
zoom

rkohan
28th Feb 2008, 06:27 pm
I am still getting the same result. Pretty soon I may have to do the files (49) one by one.

Any help would be appreciated.

Thanks

erik_NL
28th Feb 2008, 06:30 pm
I am still getting the same result. Pretty soon I may have to do the files (49) one by one.

Any help would be appreciated.

Thanks

as far as i see; you really do have to add an enter ( not the brackets ! )
:)



edit1
you'r using the script from page 4 ????





-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




- i did add a enter. So just copy and past. one enter after quit ( last line )( one enter and only one ) when copy and pasting !
No testing facilities at the moment.

rkohan
28th Feb 2008, 06:36 pm
I did ad the enter. Still no luck. I was just looking at the autocad command printout that I included. at the last 2 keyins: second to last:zoom is keyed in but not an option therefore an invalid option keyword, last keyin, no keyin is typed in but canceled. Is there something missing here? I don't know what I/.scr should be typing in?

erik_NL
28th Feb 2008, 06:42 pm
I did ad the enter. Still no luck. I was just looking at the autocad command printout that I included. at the last 2 keyins: second to last:zoom is keyed in but not an option therefore an invalid option keyword, last keyin, no keyin is typed in but canceled. Is there something missing here? I don't know what I/.scr should be typing in?

it's wrong with the layer command.
layer ;rem-layercommand
lock ;rem-lock layers
* ;rem-all layers
;rem-here a enter to exit the layer command
zoom ;rem-here sequence for other commands
etc
etc
etc


That should do the trick.

was trying to add spaces to clearify the lines but that wouldn't work. so i added ;rem-

you can also type it in at your commandline, you can see what is happening.

otherwise;
do paste your code again here.

rkohan
28th Feb 2008, 06:51 pm
I ran all of the key in commands manually on a dummy file and it still has xrefs. Here is what I am using:



-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

Can you edit it for me. I'm just not understanding you. Dense I guess.

rkohan
28th Feb 2008, 09:02 pm
OK. I got it to run. The problem is, it isn't binding the drawings. I copied all of the drawings into a seperate Issued drawings folder, copied the issueroutine.bat there and double clicked it. It ran through every file but when it was done and I opened the drawings, they still had references. Did the program put them somewhere else? Am I missing something?

LElkins
28th Feb 2008, 10:19 pm
rkohan,
Do you have any unloaded xrefs, unreferenced or nested?
If you do then it won't bind the xrefs.

Cheers

JeepMaster
29th Feb 2008, 07:38 am
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)
)
)
)
Try my lisp to see if it helps.

rkohan
29th Feb 2008, 01:11 pm
Thanks for all the help. But I need to know how to run this code. Can you give me a step by step? Remember, I'm new.

erik_NL
29th Feb 2008, 01:13 pm
Thanks for all the help. But I need to know how to run this code. Can you give me a step by step? Remember, I'm new.

The code above;
put this code in a file ( just like the other one ). This file has to end with .lsp
load it in acad with appload
run it with sent in autocad.

rkohan
29th Feb 2008, 01:15 pm
and it will run on multiple files?

erik_NL
29th Feb 2008, 01:19 pm
and it will run on multiple files?

No, not that i know.

rkohan
29th Feb 2008, 01:45 pm
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.

LElkins
29th Feb 2008, 01:47 pm
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

JeepMaster
29th Feb 2008, 04:09 pm
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.

uthay
14th Mar 2008, 05:29 pm
Hi LElkins

i couldn't find the link to download your vba program zip. please post the link again , thanks

cadmaker
21st May 2008, 05:07 pm
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

LCE
21st May 2008, 05:20 pm
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

LCE
21st May 2008, 05:35 pm
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.

cadmaker
16th Jul 2008, 03:53 pm
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

jfurlong
14th Apr 2009, 02:58 pm
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.

JeepMaster
17th Jun 2009, 04:46 pm
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)
)
)
)

asos2000
21st Jun 2009, 12:18 pm
Can I use the *.scr code as a macro?

Lee Mac
21st Jun 2009, 01:29 pm
Can I use the *.scr code as a macro?

Do you mean you want to run the script from a toolbar button?

Lee Mac
21st Jun 2009, 11:32 pm
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...



(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_reload (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))

asos2000
8th Jul 2009, 09:00 am
LEE

what is it mean
<< Error: no function definition: X_RELOAD >>
and how is this lisp deal with unloaded Xrefs

JeepMaster
8th Jul 2009, 03:04 pm
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.:P

Lee Mac
8th Jul 2009, 06:54 pm
LEE

what is it mean
<< Error: no function definition: X_RELOAD >>
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))

JeepMaster
8th Jul 2009, 08:49 pm
Thanks LeeMac,
Your lisp seems to work great. It even report back the problem xrefs...Cool!:D Now only if I know what all those code means.

JeepMaster
8th Jul 2009, 09:14 pm
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?

Lee Mac
9th Jul 2009, 01:24 am
I'm not sure why it doesn't like the purgeall, but oh well, you could always change it back to (command "_.-purge"...)

As for adding another function, I hate doing it, but if you must, I would add it just after the vla-purgeall, and call it like:



(c:PAA)

asos2000
9th Jul 2009, 09:00 am
LEE MAC

its great lisp
but there is a quastion, what habbens with unloaded Xrefs?

JeepMaster
9th Jul 2009, 01:09 pm
LEE MAC

its great lisp
but there is a quastion, what habbens with unloaded Xrefs?

Unloaded xrefs gets detached...or at least that's what my original lisp does.

JeepMaster
9th Jul 2009, 04:17 pm
LeeMac,
Okay, so I've added my purge code in and it works fine. But now I can't see the list of problem xrefs because during purging, all the activity bump the command screen down. How can I list the problem xrefs in the end of the code?

(strcat "\n<< XREF: " (car xref)" Failed to Bind >>")
Here's what I have so far.

(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*"))
(setvar "modemacro" ".")
(princ))

(setq doc (vla-get-ActiveDocument
(vlax-get-acad-object)))
(vla-StartUndoMark doc)
(setvar "modemacro" "Audit/Bind/PurgeAll processing......please wait......")
(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 >>"))
(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 "modemacro" ".")
(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))

Thanks for the help so far Lee Mac.

asos2000
9th Jul 2009, 04:20 pm
Could the next version of this lisp bind a list of drawings without openning it?

Lee Mac
9th Jul 2009, 04:20 pm
Two options:


1)


(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*"))
(setvar "modemacro" ".")
(princ))

(setq doc (vla-get-ActiveDocument
(vlax-get-acad-object)))
(vla-StartUndoMark doc)
(setvar "modemacro" "Audit/Bind/PurgeAll processing......please wait......")
(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 >>"))
(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 "modemacro" ".")
(textscr)
(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))
2)



(defun c:sent (/ *error* doc xlst dfile lst)
(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*"))
(setvar "modemacro" ".")
(princ))

(setq doc (vla-get-ActiveDocument
(vlax-get-acad-object)))
(vla-StartUndoMark doc)
(setvar "modemacro" "Audit/Bind/PurgeAll processing......please wait......")
(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 >>"))
(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 "modemacro" ".")
(if lst
(mapcar 'princ (reverse lst)))
(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))

Lee Mac
9th Jul 2009, 04:21 pm
Could the next version bind a list of drawings without openning it?

A lot more work involved and I'm not getting paid... :glare:

asos2000
9th Jul 2009, 04:31 pm
is praying enough for you, or u wanna more?

JeepMaster
9th Jul 2009, 04:49 pm
That is excellent LeeMac. I used the 2nd option because I use it on batch scripts alot and don't want to have another pop up while running batch scripts. It works awsome! Thanks so much.
I'd buy you a beer if only I could reach over the computer to you. :)

Lee Mac
9th Jul 2009, 06:21 pm
That is excellent LeeMac. I used the 2nd option because I use it on batch scripts alot and don't want to have another pop up while running batch scripts. It works awsome! Thanks so much.
I'd buy you a beer if only I could reach over the computer to you. :)

Glad you like it :)

Lee

otil
20th Jul 2009, 12:04 pm
Anyone who have a script to purge multiple sheets at same time?

Lee Mac
20th Jul 2009, 01:07 pm
See here

http://www.cadtutor.net/forum/showthread.php?t=38269 (http://www.cadtutor.net/forum/showthread.php?t=38269)

otil
20th Jul 2009, 01:23 pm
See here

http://www.cadtutor.net/forum/showthread.php?t=38269 (http://www.cadtutor.net/forum/showthread.php?t=38269)


Dear Sir,

It worked but only to one drawing. what I need is to automate purge in multiple sheets.

Lee Mac
20th Jul 2009, 01:24 pm
Dear Sir,

It worked but only to one drawing. what I need is to automate purge in multiple sheets.

It should work on every drawing that it open - so you can open all the drawings you want it done to, and run it :)

JeepMaster
20th Jul 2009, 03:52 pm
Or you can use batch script programs like ScriptPro and run your scripts to a folder of drawings. I personally like using SuperScript, it's much faster and doesn't close/reopen autocad on every drawing.
The script then would just be something very simple like:

PurgeAll
QSave

otil
21st Jul 2009, 05:46 am
Or you can use batch script programs like ScriptPro and run your scripts to a folder of drawings. I personally like using SuperScript, it's much faster and doesn't close/reopen autocad on every drawing.
The script then would just be something very simple like:

PurgeAll
Save


Thank you Mr. Jeep Master, that exactly I want to run script to my drawing folder. The Code the you give me is just like that how to execute that. I am not very familiar using ScriptPro and superscript. Would you like to help me to further. Thanks a lot I learned a lot.
Sorry for my grammar I am not a english man, Im from Philippines

JeepMaster
21st Jul 2009, 03:10 pm
Here's a simple tutorial showing how to use scriptpro. I'm linking you to this since scriptpro is free and you might even have it on your machine already. It's part of AutoCAD if you have it installed during setup.
http://www.lazydrafter.com/autocad-tips/scriptpro/

To write the actual script, just open notepad from your computer and type in:
PurgeAll
QSave

Save the file with "scr" extension. Like: PurgeAll.scr
Now use this file as per the tutorial. I hope it works out for you.:)

otil
22nd Jul 2009, 06:00 am
Here's a simple tutorial showing how to use scriptpro. I'm linking you to this since scriptpro is free and you might even have it on your machine already. It's part of AutoCAD if you have it installed during setup.
http://www.lazydrafter.com/autocad-tips/scriptpro/

To write the actual script, just open notepad from your computer and type in:
PurgeAll
QSave

Save the file with "scr" extension. Like: PurgeAll.scr
Now use this file as per the tutorial. I hope it works out for you.:)


Thanks Mr. jeepmaster! I will come back to you if there any problem I might be encountered. Thanks a lot Hope you don;t mind

jfurlong
13th Aug 2009, 10:22 am
Lee Mac
Thank you and jeepmaster for your lsp.:D
They work great for me in 2008 acad but i'm now upgrading to 2010 acad.
In 2010 I get a problem that it will not bind Xref’s who status is not found .
This did work in 2008, in 2009 it worked but reported it didn't for some reason.
Could the problem be that all dwg's are not in 2010 format?
Or do you have any other ideas why it isn't working?

jfurlong
13th Aug 2009, 11:21 am
hey guys,

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

acad can be funny but anyway thaks for all the info
next part is to save the file with a new, add a custom layout i have (blank except a disclaimer) then do an exportlayout. this way the model space bound dwg's that we issue will have our disclaimer at the approbriate scale.

then if i can only get this to run as a batch file on muliiple files on a folder, then i will be much loved around my office.:D:D

2010 lsp


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

2008 lsp


(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_reload (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))

jfurlong
13th Aug 2009, 11:22 am
be the way once i have made the extra addons i was talking about above i will post up here.

JeepMaster
13th Aug 2009, 05:10 pm
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.

Lee Mac
13th Aug 2009, 08:13 pm
Jeep,

I never tested the version I wrote - but I do have 2010 to test, so shall look into it when I get a minute. :)

jfurlong
14th Aug 2009, 09:33 am
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.

JeepMaster
22nd Sep 2009, 06:39 pm
jfurlong,
What's the status of your modified lisp? What did you do to make it work for 2010?

jfurlong
23rd Sep 2009, 10:41 am
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.

JeepMaster
5th Oct 2009, 03:40 pm
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.

jfurlong
5th Oct 2009, 03:43 pm
hi this is possible, i will get back to this soon, at the moment i'm too busy trying to crack the slowness of autocad 2010.

bugoy202
28th Jul 2010, 06:14 pm
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

kam1967
8th Feb 2011, 07:12 pm
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.
[code];................................................. ..............................
;
; << 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)

clyde88
24th May 2011, 03:39 pm
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

sidhu412
24th Oct 2011, 11:50 am
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