Jump to content

Batch Purge & Audit


Rhayes

Recommended Posts

  • 2 years later...
Is there a Lisp Routine that will do a Batch Purge and Audit on an Entire Drawing folder.???

 

I just moved into this thread because I need to audit a big bunch of drawings because of my "entire web autocad block compilation task"

 

;;;CADALYST 03/05 Tip2023: PurgeFiles.lsp Directory Clean Up (c) Andrzej Gumula

;;; [c]2004 Andrzej Gumula, Katowice, Poland
;;; e-mail: [email="a.gumula@wp.pl"]a.gumula@wp.pl[/email]
;;; This routine purge dwg files from selected folder

(vl-load-com)
(defun c:PurgeAuditFiles (/ FilesList DwgPath 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 ""))
  (cond
   ((not (vl-catch-all-error-p (vl-catch-all-apply 'vlax-invoke-method (list Dir 'Items))))
    (setq Item (vlax-invoke-method (vlax-invoke-method Dir 'Items) 'Item))
    (setq Path (vla-get-path Item))
    (if (not (member (substr Path (strlen Path) 1) (list "/" "\\")))
     (setq Path (strcat Path "\\"))
    );end if
   )
  );end cond
 )
);end cond
Path
);end GetFolder

(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 if
)
(reverse AllPath)
);end vl-findfile
(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)))
  (foreach Item TmpList (MakeDirList (strcat Arg "/" Item)))
 )
);end cond
);end MakeDirList
(if (not FileSystemObject)
 (setq FileSystemObject (vla-getInterfaceObject (vlax-get-acad-object) "Scripting.FileSystemObject"))
);end if
(cond
((= (getvar "SDI") 0)
(cond
((setq DwgPath (GetFolder))
 (initget "Yes No")
 (setq Subdir (cond ((getkword "\nLooking for subfolders? No,[Yes]: "))
      (T "Yes")))
 (if (equal SubDir "Yes")
  (setq Files (vl-findfile (substr DwgPath 1 (1- (strlen DwgPath)))))
  (setq Files (mapcar '(lambda (x) (strcat dwgpath x))(vl-directory-files DwgPath "*.dwg" 1)))
 );end 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)))
    (foreach & Files
     (cond
((not (member & FilesList ))
        (cond
  ((/= (logand (vlax-get-property (vlax-invoke-method FileSystemObject 'getfile &) 'Attributes) 1) 1)
   (cond
     ((setq File (vla-open (vla-get-documents (vlax-get-acad-object)) &))
      (prompt (strcat "\nPurge " & ". Please wait..."))
             (vla-purgeall 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 cond
  )
  (T (prompt (strcat & " is read-only. Purge canceled. ")))
 );end cond
)
(T (prompt (strcat & " is open now. Purge canceled. ")))
     );end cond
    );end foreach
   )
   (T (prompt "\nNothing files found to purge. "))
 );end cond
)
(T (prompt "\nNothing selected. "))
);end cond
)
(T (prompt "\nThe routine is not available in SDI mode. "))
);end cond
(princ)
);end c:PurgeFile
(prompt "\nLoaded new command PurgeFiles. ")
(prompt "\n[c]2004 Andrzej Gumula. ")
(princ)

 

I added the

(vla-AuditInfo File T)

to audit all files.

 

:)

 

This post is not a question, just Sharing the info.

I think I will try to use this lisp for Batch plotting... I still don´t know if its possible, but I'll try it.

  • Like 1
Link to comment
Share on other sites

I think I will try to use this lisp for Batch plotting... I still don´t know if its possible, but I'll try it.

Try it

PlotDwgs.lsp - PlotDwgs is a plot utility program with several unique options including plotting all open drawings, and plotting a folder of user selected drawings. Drawings may be plotted to a specified size, or by selecting the "Varies" option, the program determines the correct paper size to plot. Also included is the option of plotting all layouts in reverse order, and plotting a folder of user selected drawings in reverse order. The associated files are PlotDwgs.lsp, PlotDwgs.dcl and PlotDwgs.dvb.

Link to comment
Share on other sites

You can also use ScriptPro, a free utility from AutoDesk, to batch process multiple AutoCAD files. Quoting Helen Gorina from her AutoDesk University (2007) lecture on How to Clean Anything in AutoCAD...

 

"ScriptPro runs outside of AutoCAD. It starts a session of AutoCAD for every file on the list, runs the script then closes the session of AutoCAD and starts on the next file."

 

Helen has included an example of a script that purges, audits then saves a drawing file. The audit command runs twice. Once for model space entities and once for layout entities.

 

You can find this article by visiting AutoDesk University Online.

 

http://au.autodesk.com/

 

You must sign up to access the site.

Link to comment
Share on other sites

Try it

PlotDwgs.lsp - PlotDwgs is a plot utility program with several unique options including plotting all open drawings, and plotting a folder of user selected drawings. Drawings may be plotted to a specified size, or by selecting the "Varies" option, the program determines the correct paper size to plot. Also included is the option of plotting all layouts in reverse order, and plotting a folder of user selected drawings in reverse order. The associated files are PlotDwgs.lsp, PlotDwgs.dcl and PlotDwgs.dvb.

 

I will try it this afternoon....

It may work

Link to comment
Share on other sites

  • 9 years later...

Hi,

I want to perform below actions using lisp. How can I do? Can you guys help me out in this?

 

  1. Ask for folder

  2. After selecting folder Open the DWG

  3. Go to Model

  4. Grid off

  5. Purge all 3 times

  6. Zoom Extend

  7. Come back to Layout

  8. Zoom Extend

  9. Save

  10. Close

Link to comment
Share on other sites

  1. Ask for folder use (findfile ......

  2. After selecting folder Open the DWG see item 1

  3. Go to Model (setvar 'cvport "MODEL)

  4. Grid off (command "grid" "Off")

  5. Purge all 3 times (command "-purge" "all" ..... etc 3 times

  6. Zoom Extend (command "zoom" "E")

  7. Come back to Layout 2a (setq lay (getvar 'ctab)) 7 (setvar "ctab lay)

  8. Zoom Extend see 6

  9. Save (command "save" "Y")

  10. Close (command "close")

Link to comment
Share on other sites

15 hours ago, BIGAL said:
  1. Ask for folder use (findfile ......

  2. After selecting folder Open the DWG see item 1

  3. Go to Model (setvar 'cvport "MODEL)

  4. Grid off (command "grid" "Off")

  5. Purge all 3 times (command "-purge" "all" ..... etc 3 times

  6. Zoom Extend (command "zoom" "E")

  7. Come back to Layout 2a (setq lay (getvar 'ctab)) 7 (setvar "ctab lay)

  8. Zoom Extend see 6

  9. Save (command "save" "Y")

  10. Close (command "close")

All is going well if i use gilsoto13 LISP only thing is it is not coming back to layout again and saving data by Zoom Extending it. Please add this much  i am new to LISP i don't know how to make these changes

Link to comment
Share on other sites

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...