TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Keith™ on October 06, 2005, 10:21:39 AM

Title: Search for text string in closed and zipped drawings
Post by: Keith™ on October 06, 2005, 10:21:39 AM
Ok .. I an asking for a bit of help putting this together as I am currently under the gun and don't have time to do the whole shebang .. there are lots of code snippits that could likely be put together to manage what I need but there are also some things that I need to do that I have not seen  code for ... so .....

I need to search a folder (and all subfolders) for a drawing with a plain text string that I will supply .. the caveat is that all drawings are in zipped archives on a remote computer.

Pseudo code

I could probably do this in VB as well .. it may be easier .. anyway, depending upon the direction this takes I will move it to the proper forum.
Title: Re: Search for text string in closed and zipped drawings
Post by: MP on October 06, 2005, 10:41:05 AM
What I could help out (ObjectDbx, recursive directory scanning, text searching et al) you already know. All I can suggest is maybe taking advantage of winzip's command line interface (http://www.winzip.com/prodpagecl.htm).
Title: Re: Search for text string in closed and zipped drawings
Post by: JohnK on October 06, 2005, 11:36:20 AM
Couldnt you make a batch file to do this for you? (GNU, has all the commandline (un)compress utills you need.)

You could to a search with lisp, then do a findstr/batch file  in a shell [(defun shellthis (c) (command "sh" c))] and create a text file, then read that text file in lisp again. (and ofcourse delete the file with lisp.)

how does that sound?
Title: Re: Search for text string in closed and zipped drawings
Post by: Keith™ on October 06, 2005, 11:49:49 AM
Well, considering that I have to search in a closed DWG file I doubt it would work .. ObjectDBX is the solution .. but alas I will have to decompress (we don't use winzip) the dwgs from a zip and report the drawings ... I have 12 years of drawings I must research and this will no doubt take many days and possibly weeks ... unless I can automate it .. and as I said previously I am sort of under the gun and don't have too much time to devote to this right at the moment ...
Title: Re: Search for text string in closed and zipped drawings
Post by: hendie on October 06, 2005, 11:56:24 AM
Keith, you're using 2000 there aren't you ?
Superfind would do it although I'm not sure about the zipped folders.. it's been a while since I used it
Title: Re: Search for text string in closed and zipped drawings
Post by: JohnK on October 06, 2005, 01:27:19 PM
You can use just regular search in windows if its just a text string.

...Awe hold on. Let me create an example for you.

Extact this archive and open the folder (BatchTest) and dblkclick the .cmd file
Title: Re: Search for text string in closed and zipped drawings
Post by: Keith™ on October 06, 2005, 04:43:15 PM
Interesting ... I didn't think that you could search a DWG file for a text string .... you learn something new every day ...
I'll give it a shot ... I should be able to batch something relatively simply ..
Thanks ..
Title: Re: Search for text string in closed and zipped drawings
Post by: JohnK on October 06, 2005, 05:03:01 PM
Cool huh?!

Batch scripts are cool! And you can call them from a lisp too. (Like my example above.) They can make for fast work.

story: At the last office i was at they replaced the server and the company hired a seperate IT company to come out and do the switch. They had two guys out for hours (late at night) going to each and every machine unmapping and remapping dirves i guess. So when i showed a guy in the office how cool batch scrips were, i just happned to pick the topic of maping drives. I quickly whiped up a lil batch to map all my drives up. (the script did about 10 maps in less then a second) all he did was laugh. At the time i was kinda annoyed with his attitude, but then later he told me about how much moeny the company must have spent having those two guys out remapping drives i kinda understood. (Such is life. OBTW, we never told the higher ups.)
Title: Re: Search for text string in closed and zipped drawings
Post by: CAB on October 06, 2005, 05:36:51 PM
Very cool John. :-)

Speaking of Zip files, here is another program I use.
http://www.pdf995.com/suite.html

I have it set up so that I can run my PlotTabs Routine & print an entire drawing (8-12 tabs)
to pdf files hands free so to speak.

Sorry I digress.
Title: Re: Search for text string in closed and zipped drawings
Post by: Keith™ on October 07, 2005, 08:49:44 AM
I have done hundreds of batch programs, I even wrote batch programs that did things batch programs were not supposed to be able to do ... many years ago I investigated the possibility of a text based memory resident virus ... to this date I have not ever seen anything like it in the wild, but I successfully created a self replicating text based batch file.

Back to my original comments ... I thought that the entity information in a drawing was compressed to the point that you could not determine if a specific text string existed by doing a text search on the DWG.
Title: Re: Search for text string in closed and zipped drawings
Post by: JohnK on October 07, 2005, 08:53:51 AM
Well then your an old hand at 'em. (You need to be teachin me!) I know those things can get uite involoved. MP re-did a batch for me and i still refer to it for help. It just has so much i can learn from in it.

So did you preform the search yet or is that sched for this weekend? (How did it work?)
Title: Re: Search for text string in closed and zipped drawings
Post by: Keith™ on October 07, 2005, 09:03:23 AM
I have adjusted the routine to search for the string I need to find and a few other minor tweaks .. but I still need to add recursion to it ..

I'll post the code when I get it done ...
Title: Re: Search for text string in closed and zipped drawings
Post by: M-dub on October 07, 2005, 09:40:16 AM
I know it's late in the game here, but I was going to post a link to DrawingSearcher (Now called Docupoint Discovery) which does a string search through all of your dwg's (to make a long story short), but I tested it with zip files and it doesn't help with that.  That's why I didn't post this link -> www.docupoint.com
Title: Re: Search for text string in closed and zipped drawings
Post by: MP on October 07, 2005, 09:46:51 AM
Kinda late in the day and I didn't see anyone post this (forgive if they did and my coffee bereft eyes didn't see it) but there is the DOS find command (supports redirection), which can be used with the for command.
Title: Re: Search for text string in closed and zipped drawings
Post by: JohnK on October 07, 2005, 09:53:44 AM
I used "findstr" would that be a good enough?
Title: Re: Search for text string in closed and zipped drawings
Post by: MP on October 07, 2005, 10:00:08 AM
Coffee, must get coffee.

 :oops:
Title: Re: Search for text string in closed and zipped drawings
Post by: Keith™ on October 07, 2005, 12:22:36 PM
Ok .. this is what I did ...
Code: [Select]
@echo off
::Change the next line to the root of where you want to start searching files
set BEGINPATH=X:\DWGS\OldDDrive\
echo Search will start in %BEGINPATH%
pause
::dir /a /s /b %BEGINPATH%*.ZIP > temp.txt
::extract all DWG files
For /F "tokens=1* delims= " %%f in ('dir /a /s /b %BEGINPATH%*.ZIP') do unzip.exe -j "%%f %%g" -d tmp/
::if there are any DWG files not compressed copy them as well
For /F "tokens=1* delims= " %%f in ('dir /a /s /b %BEGINPATH%*.DWG') do copy "%%f %%g" .\tmp
::search all DWG files
findstr "L0272" .\tmp\*.dwg
::now lets clean up behind ourselves
For /F "tokens=1* delims= " %%f in ('dir /a /s /b .\tmp\*.dwg') do erase "%%f %%g"
pause
set BEGINPATH=

The result was 8453 files searched took right at 2 hours to extract, search, and cleanup .... regardless of how long it took ... it certainly saved me hours upon hours of manual searching ...
Title: Re: Search for text string in closed and zipped drawings
Post by: JohnK on October 07, 2005, 03:02:39 PM
So you found the dwg(s) okay then?
Title: Re: Search for text string in closed and zipped drawings
Post by: Keith™ on October 07, 2005, 03:26:24 PM
Actually I didn't find them ... but the tool did work for what it was designed to do ... anyway I will keep it handy for future use.

I'll likely expand it a bit and make it a little more user friendly ...