我想我已经采纳了你们的建议。这是我到目前为止得到的。当我手动运行审计时,仍然会出现很多错误,即使lisp应该审计图形文件3次。
-
- (defun c:scrubdwg (/ *error* uFlag)
- (vl-load-com)
- (defun *error* (msg)
- (and uFlag (vla-EndUndoMark *doc))
- (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
- (princ (strcat "\n** Error: " msg " **")))
- (princ))
- (setq *doc (cond (*doc)((vla-get-ActiveDocument
- (vlax-get-acad-object)))))
- ;;; Set UCS to world
- (setvar "cmdecho" 0)(command "._ucsfollow" "1")
- (command "._ucs" "_w")(command "._ucsfollow" "0")
- ;;; Detach all xrefs
- (command "._-xref" "_D" "*")
- ;;; Delete all layout tabs
- (vlax-for lay (vla-get-layouts *doc)
- (if (not (eq "MODEL" (strcase (vla-get-Name lay))))
- (vla-delete lay)))
- ;;; Changes all layers to thaw, on, unlock, and .25mm lineweight. Set current layer to 0.
- (command "._-layer" "_t" "*" "_on" "*" "_u" "*" "_s" "0" "_lw" "0.25" "*" "")
- ;;; Delete all layer filters
- (vl-catch-all-apply
- '(lambda ()
- (vla-remove
- (vla-getextensiondictionary
- (vla-get-layers
- (vla-get-activedocument (vlax-get-acad-object))
- ) ;_ end of vla-Get-Layers
- ) ;_ end of vla-GetExtensionDictionary
- "AcLyDictionary"
- ) ;_ end of vla-Remove
- ) ;_ end of lambda
- ) ;_ end of vl-Catch-All-Apply
- ;;; Delete all layer states
- (if (setq states (layerstate-getnames t t))
- (mapcar (function layerstate-delete) states))
- ;;; Delete all named views
- (command "._-view" "_s" "junk")(command "._-view" "_d" "*")
- ;;; Set insertion basepoint to 0,0,0
- (command "._insbase" "0,0,0")
- ;;; Set overall, modelspace, and paperspace linetype scales to 1
- (command "._ltscale" 1)(command "._msltscale" 1)(command "._psltscale" 1)
- ;;; Set annotation scale to 1/4" = 1'-0"
- (command "._cannoscale" "1/4\042 = 1'-0\042")
- ;;; Delete unused scales
- (command "._-scalelistedit" "_d" "*" "_e")
- ;;; Delete all dimensions
- (if (setq ss (ssget "_x" (list (cons 0 "*dimension"))))
- (command "_erase" ss "")
- )
- ;;; Set all object colors to bylayer
- (command "._setbylayermode" "1")
- (command "._setbylayer" "_all" "" "_y" "_y")
- ;;; Erase x data
- (command "._erase" (ssget"x") "r")(setvar 'cmdecho 1)(princ))
- ;---------------------------------------------------------------------------------------------------------
- (defun c:scrubdwg2 ()
- ;;; Delete all regapps, run an audit on the drawing file, and purge all unused items
- (setvar "cmdecho" 0)
- (command "._-layer" "_s" "0" "")
- (repeat 3
- (command "._-purge" "_r" "" "_n")
- (command "._audit" "_y")
- (command "._-purge" "_a" "*" "_n")
- )
- ;;; Zoom extents
- (command "._zoom" "_e")
- (setvar "cmdecho" 1)
- (princ))
|