Author Topic: Purge all drawings in directory  (Read 7426 times)

0 Members and 1 Guest are viewing this topic.

vinnyg

  • Guest
Purge all drawings in directory
« on: March 16, 2007, 03:26:18 PM »
HI all,

Just a quick question.....can a group of drawings located in one directory
be purged at once without opening each drawing?

If so, how?

thanks,

vinny

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Purge all drawings in directory
« Reply #1 on: March 16, 2007, 03:53:01 PM »
HI all,

Just a quick question.....can a group of drawings located in one directory
be purged at once without opening each drawing?

If so, how?

thanks,

vinny
Not that I know of.  What do you want to get rid of?  You can erase some items with ObjectDBX from drawings that are not opened in the editor.  If you want to purge them all (command version) then I think you will have to write a script.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

vinnyg

  • Guest
Re: Purge all drawings in directory
« Reply #2 on: March 16, 2007, 05:28:05 PM »
I want to purge all unused items. Don't know the first thing about writing a script that would
do something like this. Thanks for your help,

vinny

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Purge all drawings in directory
« Reply #3 on: March 16, 2007, 05:43:54 PM »
Do you know how to do it manually ? for one drawing ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Purge all drawings in directory
« Reply #4 on: March 16, 2007, 05:45:43 PM »
Wouldn't be to hard.  For what you want, something like
Code: [Select]
((lambda (/ FullPath DwgList Opened DirPath)

(if
 (and
  (setq FullPath (getfiled "Select drawing within directory to purge." "" "dwg" 4))
  (setq DwgList (vl-directory-files (setq DirPath (vl-filename-directory FullPath)) "*.dwg" 1))
  (setq Opened (open "c:/TempScript.scr" "w"))
 )
 (foreach Dwg DwgList
  (write-line "_.open" Opened)
  (write-line (strcat "\"" DirPath "\\" Dwg "\"") Opened)
  (write-line "_.purge" Opened)
  (write-line "_all" Opened)
  (write-line "*" Opened)
  (write-line "_no" Opened)
  (write-line "_.qsave" Opened)
  (write-line "_.close" Opened)
 )
)
(and
 Opened
 (close Opened)
)
(princ)
))
Then just run the command 'script' from within Acad, and select the script that we just made title 'TempScript.scr' in the root 'c:' folder (can be changed).
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

VVA

  • Newt
  • Posts: 166
Re: Purge all drawings in directory
« Reply #5 on: March 17, 2007, 04:07:02 AM »

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Purge all drawings in directory
« Reply #6 on: March 17, 2007, 12:48:03 PM »
If you can purge with ObjectDBX then you can purge the entire folder by looping through each drawing in the folder ...
There is a BrowseForFolder api located elsewhere in this forum .. if you implement that in VBA along with the ObjectDBX libraries, you will be able to do that.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Purge all drawings in directory
« Reply #7 on: March 17, 2007, 06:47:53 PM »
If you can purge with ObjectDBX then you can purge the entire folder by looping through each drawing in the folder ...

Can you ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Purge all drawings in directory
« Reply #8 on: March 18, 2007, 03:07:08 AM »
If you can purge with ObjectDBX then you can purge the entire folder by looping through each drawing in the folder ...

Can you ?
Not that I know of.  The purge method is only available to the ActiveDocument.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Purge all drawings in directory
« Reply #9 on: March 18, 2007, 05:12:42 AM »
If you can purge with ObjectDBX then you can purge the entire folder by looping through each drawing in the folder ...

Can you ?
Not that I know of.  The purge method is only available to the ActiveDocument.

That is my knowledge also Tim.
Keith seems to have different information.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Chuck Gabriel

  • Guest
Re: Purge all drawings in directory
« Reply #10 on: March 18, 2007, 08:55:58 AM »
If you can purge with ObjectDBX then you can purge the entire folder by looping through each drawing in the folder ...

Can you ?
Not that I know of.  The purge method is only available to the ActiveDocument.

That is my knowledge also Tim.
Keith seems to have different information.


You could probably "fake it" by deleting symbol table records that are unreferenced, but there is significant danger of corrupting drawings that way.  It just seems to easy to screw up.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Purge all drawings in directory
« Reply #11 on: March 18, 2007, 11:12:55 AM »
you guys seem to be missing the point here ... first off .. I stated "IF" you could purge with ObjectDBX. It seems Chuck is on the right track .. you can delete anything from the drawing, you just need to make sure you are not deleting somethingthat will corrupt the drawing. Preliminary tests on my end, show that you can safely delete unreferenced layers, linetypes, textstyles, blocks and mlines. The delete method will fail if the object is referenced and a runtime error will result. When deleting blocks from a dbx document, AutoCAD will crash if you attempt to save the drawing. You will need to do a saveas to a new file. Once you have successfully saved the file, you can remove the reference to the original file, delete it and rename the new file to the original name.

I have reviewed some code for a project built in .net that also suggests there is a mechanism by which .net libraries have additional safety built into them when writing out drawings using ObjectDBX, but I am not at liberty to disclose that code.

Suffice to say, I don't think you will accomplish this without lots of coding and error checking, especially not in lisp.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

vinnyg

  • Guest
Re: Purge all drawings in directory
« Reply #12 on: March 19, 2007, 10:02:15 AM »
Thanks to everyone for your input and suggestions.
I will review all the comments and try all that seem safe enough, ie: those that
won't destroy my drawings or cause Autocad to crash. Thanks again,

vinnt

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Purge all drawings in directory
« Reply #13 on: March 19, 2007, 11:23:06 AM »
Keith™,

I said you could delete items from within a drawing opened with ObjectDBX, but you couldn't purge, so I don't think I got your idea wrong.  I have had problems with erasing mline definitions in the dictionary (iirc) that are in use, so you would have to search the drawing for any mlines, then save the name of the style, then make sure the style isn't in your list before you delete it.

Vinny,

You're welcome.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Purge all drawings in directory
« Reply #14 on: March 19, 2007, 11:26:43 AM »
Keith™,

I said you could delete items from within a drawing opened with ObjectDBX, but you couldn't purge, so I don't think I got your idea wrong.  I have had problems with erasing mline definitions in the dictionary (iirc) that are in use, so you would have to search the drawing for any mlines, then save the name of the style, then make sure the style isn't in your list before you delete it.

Vinny,

You're welcome.


Correct, there is no purge method, but there is a delete method for all objects, including tables, thus you CAN iterate through all of the blocks in the block table and delete those not referenced, the same is true for linetypes, mline styles, textstyles, dimension styles, etc ...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie