Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
;;
;;
;; Evaluates a function on all drawings in a supplied list ;;
;; or in a selected directory (and subdirectories)
;;
;;------------------------------------------------------------;;
;; Author: Lee Mac, Copyright 2011 - www.lee-mac.com
;;
;;------------------------------------------------------------;;
;; Arguments:
;;
;; foo
- a function taking a two arguments
;;
;;
(the ODBXDocument) and (the ActiveDocument)
;;
;;
;;
;; dwglst - [Optional] List of DWG Filenames, if nil,
;;
;;
BrowseForFolder Dialog is displayed
;;
;;
;;
;; save - Boolean flag determining whether drawings should ;;
;;
be saved after function evaluation (T=saved)
;;
;;------------------------------------------------------------;;
;; Returns: List of ((<DWGFilename> . <FunctionResult>)...) ;;
;;
;;
;; <DWGFilename>
is the drawing filename string
;;
;; <FunctionResult> is the result of evaluating the function ;;
;; 'foo' on the document object representing the drawing
;;
;; filename - note: this could be an Error Object
;;
;;------------------------------------------------------------;;
(defun LM:ODBX ( foo dwglst save / *error* _ReleaseObject acapp acdoc acdocs dbx
dbxx dbxdoc err path result ) (vl-load-com)
(setq acapp (vlax-get-acad-object)
acdoc (vla-get-ActiveDocument acapp)
acdocs (vlax-for x (vla-get-documents acapp) (setq acdocs (cons (cons (s
trcase (vla-get-fullname x)) x) acdocs)))
dbxdoc (LM:ObjectDBXDocument acapp)
)
(defun *error* ( msg )
(mapcar '_ReleaseObject (list dbx dbxdoc))
(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n** Error: " msg " **")))
(princ)
)
(defun _ReleaseObject ( obj )
(and obj (eq 'VLA-OBJECT (type obj)) (not (vlax-object-released-p obj))
(not
(vl-catch-all-error-p
(vl-catch-all-apply
(function vlax-release-object) (list obj)
)
)
)
)
)
(if
(setq dwgLst
(cond
( dwgLst )
( (setq Path (LM:DirectoryDialog "Select Directory to Process" nil 832))
)
)
)
)
)
(if Self (vlax-release-object Self))
(if Fold (vlax-release-object Fold))
(if Shell (vlax-release-object Shell))
Path
)
;;--------------------=={ Get All Files }==-------------------;;
;;
;;
;; Retrieves all files or those of a specified filetype that ;;
;; reside in a directory (and, optionally, subdirectories) ;;
;;------------------------------------------------------------;;
;; Author: Lee Mac, Copyright 2011 - www.lee-mac.com
;;
;;------------------------------------------------------------;;
;; Arguments:
;;
;; Dir
- Directory to search
;;
;; Subs
- Boolean, if T, subdirectories are included
;;
;; Filetype - (optional) Filter for filetype (DOS pattern) ;;
;;------------------------------------------------------------;;
;; Returns: List of filenames, else nil if none are found ;;
;;------------------------------------------------------------;;
(defun LM:GetAllFiles ( Dir Subs Filetype / _GetSubFolders )
(defun _GetSubFolders ( folder )
(apply 'append
(mapcar
(function
(lambda ( f )
(cons (setq f (strcat folder "\\" f)) (_GetSubFolders f))
)
)
(vl-remove "." (vl-remove ".." (vl-directory-files folder nil -1)))
)
)
)
(apply 'append
(mapcar
(function
(lambda ( Filepath )
(mapcar
(function
(lambda ( Filename ) (strcat Filepath "\\" Filename))
)
(vl-directory-files Filepath Filetype 1)
)
)
)
(cons Dir (if subs (_GetSubFolders Dir)))
)
)
)
;;-----------------=={ ObjectDBX Document }==-----------------;;
;;
;;