highrez2 Posted June 19, 2014 Share Posted June 19, 2014 Looking for a solution to search thousands of dwg's to see if they have a region in them. And if so display this list or save the list for later use. Quote Link to comment Share on other sites More sharing options...
MSasu Posted June 19, 2014 Share Posted June 19, 2014 Create a list of files to be investigated using a BAT file with statement below: DIR /b *.DWG > MyDrawingsList.SCR After build from it a script like below (one line for each file) - adjust the colored parts: _OPEN "[color=blue]C:\MyDrawings\Drawing1st.dwg[/color]" (if (ssget "_X" '((0 . "REGION"))) (progn (setq fis (open "[color=magenta]C:\\RegionQueryResults.txt[/color]" "a")) (write-line "[color=blue]Drawings1t.dwg[/color]" fis) (close fis))) _CLOSE _OPEN "[color=blue]C:\MyDrawings\Drawing2nd.dwg[/color]" (if (ssget "_X" '((0 . "REGION"))) (progn (setq fis (open "[color=#ff00ff]C:\\RegionQueryResults.txt[/color]" "a")) (write-line "[color=blue]Drawing2nd.dwg[/color]" fis) (close fis))) _CLOSE ;end of script Use Excel to speed-up the script build. Quote Link to comment Share on other sites More sharing options...
highrez2 Posted June 19, 2014 Author Share Posted June 19, 2014 (edited) Thanks, The BAT file made the SCR file but it looks like it will only search the directory it is in... Is that correct? can I replace DIR with //SERVER_NAME/ How can I handle searching subfolders? Code: [color=blue]//SERVER_NAME/[/color] /b *.DWG > MyDrawingsList.SCR Edited June 19, 2014 by highrez2 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 19, 2014 Share Posted June 19, 2014 See this reference: http://www.robvanderwoude.com/ntdir.php The /s switch is what you require, i.e.: dir "\\SERVER_NAME\*.lsp" /s /b > mydrawingslist.scr Quote Link to comment Share on other sites More sharing options...
highrez2 Posted June 19, 2014 Author Share Posted June 19, 2014 Thanks the list works great. With my list being quite large 2726 lines (ouch), how do I export the Excel file to create the SCR file? Or is there another way to report witch files have regions in them? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 19, 2014 Share Posted June 19, 2014 To offer an alternative, load this function and then load and run the following: (defun c:findregions ( / f ) (setq f [color=red]"C:\\RegionResults.txt"[/color]) ;; Output file (LM:odbx '(lambda ( x / r ) (vl-catch-all-apply '(lambda nil (vlax-for l (vla-get-layouts x) (vlax-for o (vla-get-block l) (if (= "AcDbRegion" (vla-get-objectname o)) (progn (setq r t) (exit)) ) ) ) ) ) (if r (if (setq d (open f "a")) (progn (write-line (vla-get-name x) d) (close d)) (prompt (strcat "\nUnable to open " f)) ) ) ) nil nil ) (if (setq f (findfile f)) (startapp "notepad" f) (prompt "\nNo regions found in any drawing.") ) (princ) ) (vl-load-com) (princ) Quote Link to comment Share on other sites More sharing options...
highrez2 Posted June 19, 2014 Author Share Posted June 19, 2014 Thanks again lee I will try this out once the first method is done. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.