Jump to content

Recommended Posts

Posted

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.

Posted

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.

Posted (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 by highrez2
Posted

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?

Posted

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)

Posted

Thanks again lee I will try this out once the first method is done.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...