Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: Purge & Audit all drawing files in a folder

  1. #1
    I could stop if I wanted to rhayes.99001's Avatar
    Join Date
    2005-11
    Location
    New Jersey
    Posts
    349
    Login to Give a bone
    0

    Default Purge & Audit all drawing files in a folder

    Is there a Lisp Routine that will do a purge and audit on an entire folder of drawings.?
    I am looking for a quick way to clean a folder to archive drawings...
    I am using ADT 05'

  2. #2
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Purge & Audit all drawing files in a folder

    You can use this LINK to make a script file and batch run everything in a directory.
    just use the commands you want . . .
    (princ "._zoom ext \n" File#1 )
    (princ "._-layer s 0 \n" File#1 )
    (princ "close Yes or No \n" File#1 )


    : ) Happy Computing !

    kennet

  3. #3
    Member
    Join Date
    2005-08
    Posts
    31
    Login to Give a bone
    0

    Default Re: Purge & Audit all drawing files in a folder

    Supposedly there's a "Building Solutions Applet of the month" VREZaudit, but i can't find the link they say is on Subscription Center page

  4. #4
    Certifiable AUGI Addict robert.1.hall72202's Avatar
    Join Date
    2004-07
    Location
    Detroit Michigan
    Posts
    2,508
    Login to Give a bone
    0

    Default Re: Purge & Audit all drawing files in a folder

    Nice idea here.
    I have my save command setup to do
    a purge and zoom before I close the drawing
    I am working on. Slows down cad, but it works.

  5. #5
    I could stop if I wanted to kpblc2000's Avatar
    Join Date
    2006-09
    Posts
    212
    Login to Give a bone
    0

    Default Re: Purge & Audit all drawing files in a folder

    > Robert.Hall : do you use command or docmanager reactor?

  6. #6
    Certifiable AUGI Addict robert.1.hall72202's Avatar
    Join Date
    2004-07
    Location
    Detroit Michigan
    Posts
    2,508
    Login to Give a bone
    0

    Default Re: Purge & Audit all drawing files in a folder

    I am using the following macro:

    ^C^C-layer;set;0;;_zoom;e;-purge;a;;n;-purge;a;;n;-purge;a;;n;audit;y;qsave;close

    Gets the job done, however, it takes a few seconds.

  7. #7
    I could stop if I wanted to kpblc2000's Avatar
    Join Date
    2006-09
    Posts
    212
    Login to Give a bone
    0

    Default Re: Purge & Audit all drawing files in a folder

    Based on http://www.autocad.ru/cgi-bin/f1/board.cgi?t=31023zx and http://www.autocad.ru/cgi-bin/f1/board.cgi?t=28195cT :
    Code:
    ;|
    Based on CADALYST 03/05 Tip2023: PurgeFiles.lsp  Directory Clean Up  (c) Andrzej Gumula
      [c]2004 Andrzej Gumula, Katowice, Poland
      e-mail: a.gumula@wp.pl
    |;
    
    (vl-load-com)
    (defun dofile (curdoc)
      (vla-put-activelayer curdoc (vla-item (vla-get-layers curdoc) "0"))
      (vl-catch-all-apply '(lambda () (vla-zoomall (vlax-get-acad-object))))
      (repeat 4 (vla-purgeall curdoc))
      ) ;_ end of defun
    
    (defun c:dofile (/ fileslist subdir files file)
      (defun getfolder (/ dir item path)
        (cond
          ((setq dir
                  (vlax-invoke
                    (vlax-get-or-create-object "Shell.Application")
                    'browseforfolder
                    0
                    "Select folder with DWG files:"
                    1
                    ""
                    ) ;_ end of vlax-invoke
                 ) ;_ end of setq
           (cond
             ((not (vl-catch-all-error-p
                     (vl-catch-all-apply 'vlax-invoke-method (list dir 'items))
                     ) ;_ end of vl-catch-all-error-p
                   ) ;_ end of not
              (setq item (vlax-invoke-method
                           (vlax-invoke-method dir 'items)
                           'item
                           ) ;_ end of vlax-invoke-method
                    ) ;_ end of setq
              (setq path (vla-get-path item))
              (if
                (not (member (substr path (strlen path) 1) (list "/" "\\")))
                 (setq path (strcat path "\\"))
                 ) ;_ end of if
              )
             ) ;_ end of cond
           )
          ) ;_ end of cond
        path
        ) ;_ end of defun
    
      (defun vl-findfile (location / dirlist path allpath)
        (makedirlist location)
        (setq dirlist (cons location dirlist))
        (foreach elem dirlist
          (if (setq path (vl-directory-files elem "*.dwg"))
            (foreach item path
              (setq allpath (cons (strcat elem "/" item) allpath))
              ) ;_ end of foreach
            ) ;_ end of if
          ) ;_ end of foreach
        (reverse allpath)
        ) ;_ end of defun
    
      (defun makedirlist (arg / tmplist)
        (setq tmplist (cddr (vl-directory-files arg nil -1)))
        (cond (tmplist
               (setq dirlist (append
                               dirlist
                               (mapcar '(lambda (z) (strcat arg "/" z)) tmplist)
                               ) ;_ end of append
                     ) ;_ end of setq
               (foreach item tmplist (makedirlist (strcat arg "/" item)))
               )
              ) ;_ end of cond
        ) ;_ end of defun
      (setq *err-list* nil)
      (if (not filesystemobject)
        (setq filesystemobject
               (vla-getinterfaceobject
                 (vlax-get-acad-object)
                 "Scripting.FileSystemObject"
                 ) ;_ end of vla-getInterfaceObject
              ) ;_ end of setq
        ) ;_ end of if
      (cond
        ((= (getvar "SDI") 0)
         (cond
           ((setq dwgpath (getfolder))
            (initget 1 "Yes No")
            (setq
              subdir (cond
                       ((getkword "\nInclude subdirectories? [Yes/No]: "))
                       (t "Yes")
                       ) ;_ end of cond
              ) ;_ end of setq
            (if (equal subdir "Yes")
              (setq files
                     (vl-findfile (substr dwgpath 1 (1- (strlen dwgpath))))
                    ) ;_ end of setq
              (setq files (mapcar '(lambda (x) (strcat dwgpath x))
                                  (vl-directory-files dwgpath "*.dwg" 1)
                                  ) ;_ end of mapcar
                    ) ;_ end of setq
              ) ;_ end of if
            (setq files (mapcar 'strcase files))
            (cond
              (files
               (vlax-for & (vla-get-documents (vlax-get-acad-object))
                 (setq fileslist
                        (cons (strcase (vla-get-fullname &)) fileslist)
                       ) ;_ end of setq
                 ) ;_ end of vlax-for
               (foreach & files
                 (cond
                   ((not (member & fileslist))
                    (cond
                      ((/= (logand (vlax-get-property
                                     (vlax-invoke-method
                                       filesystemobject
                                       'getfile
                                       &
                                       ) ;_ end of vlax-invoke-method
                                     'attributes
                                     ) ;_ end of vlax-get-property
                                   1
                                   ) ;_ end of logand
                           1
                           ) ;_ end of /=
                       (cond
                         ((setq file
                                 (vla-open (vla-get-documents
                                             (vlax-get-acad-object)
                                             ) ;_ end of vla-get-documents
                                           &
                                           ) ;_ end of vla-open
                                ) ;_ end of setq
                          (prompt
                            (strcat "\nProcessing file" & ". Please wait...")
                            ) ;_ end of prompt
                          (dofile file)
                          (prompt (strcat "\nSave and close " &))
                          (vla-save file)
                          (vla-close file)
                          (vlax-release-object file)
                          )
                         (t
                          (prompt
                            (strcat
                              "\nCannot open "
                              &
                              "\nDrawing file was created by an incompatible version. "
                              ) ;_ end of strcat
                            ) ;_ end of prompt
                          )
                         ) ;_ end of cond
                       )
                      (t (prompt (strcat & " is read-only. Purge canceled. ")))
                      ) ;_ end of cond
                    )
                   (t (prompt (strcat & " is open now. Purge canceled. ")))
                   ) ;_ end of cond
                 ) ;_ end of foreach
               )
              (t (prompt "\nNothing files found to purge. "))
              ) ;_ end of cond
            )
           (t (prompt "\nNothing selected. "))
           ) ;_ end of cond
         )
        (t (prompt "\nThe routine is not available in SDI mode. "))
        ) ;_ end of cond
      (princ)
      ) ;_ end of defun
    (prompt "\n===To start press DOFILE within command prompt===")
    (princ)
    Auditing won't works using ObjectDBX interface.

  8. #8
    Member
    Join Date
    2009-07
    Posts
    45
    Login to Give a bone
    0

    Default Re: Purge & Audit all drawing files in a folder

    Quote Originally Posted by kpblc2000 View Post
    Based on http://www.autocad.ru/cgi-bin/f1/board.cgi?t=31023zx and http://www.autocad.ru/cgi-bin/f1/board.cgi?t=28195cT :
    Code:
    ;|
    Based on CADALYST 03/05 Tip2023: PurgeFiles.lsp  Directory Clean Up  (c) Andrzej Gumula
      [c]2004 Andrzej Gumula, Katowice, Poland
      e-mail: a.gumula@wp.pl
    |;
    
    (vl-load-com)
    (defun dofile (curdoc)
      (vla-put-activelayer curdoc (vla-item (vla-get-layers curdoc) "0"))
      (vl-catch-all-apply '(lambda () (vla-zoomall (vlax-get-acad-object))))
      (repeat 4 (vla-purgeall curdoc))
      ) ;_ end of defun
    
    (defun c:dofile (/ fileslist subdir files file)
      (defun getfolder (/ dir item path)
        (cond
          ((setq dir
                  (vlax-invoke
                    (vlax-get-or-create-object "Shell.Application")
                    'browseforfolder
                    0
                    "Select folder with DWG files:"
                    1
                    ""
                    ) ;_ end of vlax-invoke
                 ) ;_ end of setq
           (cond
             ((not (vl-catch-all-error-p
                     (vl-catch-all-apply 'vlax-invoke-method (list dir 'items))
                     ) ;_ end of vl-catch-all-error-p
                   ) ;_ end of not
              (setq item (vlax-invoke-method
                           (vlax-invoke-method dir 'items)
                           'item
                           ) ;_ end of vlax-invoke-method
                    ) ;_ end of setq
              (setq path (vla-get-path item))
              (if
                (not (member (substr path (strlen path) 1) (list "/" "\\")))
                 (setq path (strcat path "\\"))
                 ) ;_ end of if
              )
             ) ;_ end of cond
           )
          ) ;_ end of cond
        path
        ) ;_ end of defun
    
      (defun vl-findfile (location / dirlist path allpath)
        (makedirlist location)
        (setq dirlist (cons location dirlist))
        (foreach elem dirlist
          (if (setq path (vl-directory-files elem "*.dwg"))
            (foreach item path
              (setq allpath (cons (strcat elem "/" item) allpath))
              ) ;_ end of foreach
            ) ;_ end of if
          ) ;_ end of foreach
        (reverse allpath)
        ) ;_ end of defun
    
      (defun makedirlist (arg / tmplist)
        (setq tmplist (cddr (vl-directory-files arg nil -1)))
        (cond (tmplist
               (setq dirlist (append
                               dirlist
                               (mapcar '(lambda (z) (strcat arg "/" z)) tmplist)
                               ) ;_ end of append
                     ) ;_ end of setq
               (foreach item tmplist (makedirlist (strcat arg "/" item)))
               )
              ) ;_ end of cond
        ) ;_ end of defun
      (setq *err-list* nil)
      (if (not filesystemobject)
        (setq filesystemobject
               (vla-getinterfaceobject
                 (vlax-get-acad-object)
                 "Scripting.FileSystemObject"
                 ) ;_ end of vla-getInterfaceObject
              ) ;_ end of setq
        ) ;_ end of if
      (cond
        ((= (getvar "SDI") 0)
         (cond
           ((setq dwgpath (getfolder))
            (initget 1 "Yes No")
            (setq
              subdir (cond
                       ((getkword "\nInclude subdirectories? [Yes/No]: "))
                       (t "Yes")
                       ) ;_ end of cond
              ) ;_ end of setq
            (if (equal subdir "Yes")
              (setq files
                     (vl-findfile (substr dwgpath 1 (1- (strlen dwgpath))))
                    ) ;_ end of setq
              (setq files (mapcar '(lambda (x) (strcat dwgpath x))
                                  (vl-directory-files dwgpath "*.dwg" 1)
                                  ) ;_ end of mapcar
                    ) ;_ end of setq
              ) ;_ end of if
            (setq files (mapcar 'strcase files))
            (cond
              (files
               (vlax-for & (vla-get-documents (vlax-get-acad-object))
                 (setq fileslist
                        (cons (strcase (vla-get-fullname &)) fileslist)
                       ) ;_ end of setq
                 ) ;_ end of vlax-for
               (foreach & files
                 (cond
                   ((not (member & fileslist))
                    (cond
                      ((/= (logand (vlax-get-property
                                     (vlax-invoke-method
                                       filesystemobject
                                       'getfile
                                       &
                                       ) ;_ end of vlax-invoke-method
                                     'attributes
                                     ) ;_ end of vlax-get-property
                                   1
                                   ) ;_ end of logand
                           1
                           ) ;_ end of /=
                       (cond
                         ((setq file
                                 (vla-open (vla-get-documents
                                             (vlax-get-acad-object)
                                             ) ;_ end of vla-get-documents
                                           &
                                           ) ;_ end of vla-open
                                ) ;_ end of setq
                          (prompt
                            (strcat "\nProcessing file" & ". Please wait...")
                            ) ;_ end of prompt
                          (dofile file)
                          (vla-AuditInfo File T)
                          (prompt (strcat "\nSave and close " &))
                          (vla-save file)
                          (vla-close file)
                          (vlax-release-object file)
                          )
                         (t
                          (prompt
                            (strcat
                              "\nCannot open "
                              &
                              "\nDrawing file was created by an incompatible version. "
                              ) ;_ end of strcat
                            ) ;_ end of prompt
                          )
                         ) ;_ end of cond
                       )
                      (t (prompt (strcat & " is read-only. Purge canceled. ")))
                      ) ;_ end of cond
                    )
                   (t (prompt (strcat & " is open now. Purge canceled. ")))
                   ) ;_ end of cond
                 ) ;_ end of foreach
               )
              (t (prompt "\nNothing files found to purge. "))
              ) ;_ end of cond
            )
           (t (prompt "\nNothing selected. "))
           ) ;_ end of cond
         )
        (t (prompt "\nThe routine is not available in SDI mode. "))
        ) ;_ end of cond
      (princ)
      ) ;_ end of defun
    (prompt "\n===To start press DOFILE within command prompt===")
    (princ)
    Auditing won't works using ObjectDBX interface.

    It needed the audit command, so I added it, check above code

    (vla-AuditInfo File T)

  9. #9
    I could stop if I wanted to kpblc2000's Avatar
    Join Date
    2006-09
    Posts
    212
    Login to Give a bone
    0

    Default Re: Purge & Audit all drawing files in a folder

    AuditInfo method works only on current (active) document.

  10. #10
    Member
    Join Date
    2009-07
    Posts
    45
    Login to Give a bone
    0

    Default Re: Purge & Audit all drawing files in a folder

    Quote Originally Posted by kpblc2000 View Post
    AuditInfo method works only on current (active) document.
    Well I guess it is ok to add it that way, because I used it on a bunch of files and it worked..

    The bad thing is that this lisp stucks when opening a damaged drawing or trying to open a file that need recovery... the that file needs to be removed from the directory or open it using recover and audit inside and saving it manually to use the batch process again.

    but It works... I just finished using it for a 5,000 files directory, the lisp stopped about 30 times... but It really audited all the files... I made sure of it.

Page 1 of 3 123 LastLast

Similar Threads

  1. Purge + Audit &/or Recover + Purge
    By Wish List System in forum AutoCAD Wish List
    Replies: 3
    Last Post: 2013-06-20, 08:18 PM
  2. Purge + Audit &/or Recover + Purge
    By Wish List System in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2013-06-19, 07:12 PM
  3. 2012: Purge/Zoom Extents/Qsave a folder of DXF files
    By boyerd492098 in forum AutoCAD General
    Replies: 1
    Last Post: 2012-12-19, 08:39 AM
  4. Purge and/or Audit multiple files?
    By Maverick91 in forum CAD Management - General
    Replies: 5
    Last Post: 2010-07-13, 08:41 PM
  5. Replies: 3
    Last Post: 2006-08-04, 07:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •