Thanks for the links Mike.
I know it's been a while since your response to this thread. I haven't had a chance to further investigate my original question until now. The threads you linked me too had exactly enough information to put me in a position to write thr routine I wanted to write.
This will help a user set up projects and search paths without going through the AutoCAD options. This code could easily be customized for specific projects and paths, so the user does not even have to browse to the directories to add to the project. I wrote a generic routine so it could be used on any project, and also to have a blast off point for writing setting up specific projects and paths.
Anyways, here is the code I came up with:
Code:
;;;____________________________________________________________________________;;;
;;; ;;;
;;;ProjectFileSetup.lsp by John D. Chapman ;;;
;;;Setup Projects and Project Search Paths ;;;
;;;November 24, 2005. ;;;
;;;____________________________________________________________________________;;;
;;; ;;;
;;;If creating a new project, OR, PROJECTNAME variable has been set, ;;;
;;;but the project no longer exists in the registry, then continue to ensure ;;;
;;;the project specified in PROJECTNAME gets created or re-created. ;;;
;;;____________________________________________________________________________;;;
(defun proj_error (msg)
(if (/= msg "Function cancelled")
(princ
(strcat "\nError: " msg " [" (itoa (getvar "ERRNO")) "]")
)
(princ)
)
(proj)
(setvar "cmdecho" cmd)
(setq projName nil
projPath nil
fileprefs nil
)
(setq *error* olderr)
(princ)
)
;;;____________________________________________________________________________;;;
;;; ;;;
;;;Continue on "'<project>' not found in the registry." error. ;;;
;;;____________________________________________________________________________;;;
(defun proj (/ go prevPath fileSelect cont?)
(setq projPath nil
go T
)
(setq prevPath "\"\"")
(while go
(setq fileSelect
(getfiled
"Select a file within the directory to add (can be any file)."
prevPath
""
16
)
)
(if fileSelect
(progn
(setq prevPath (vl-filename-directory fileSelect))
(if projPath
(setq projPath (strcat projPath
";"
(vl-filename-directory fileSelect)
)
)
(setq projPath (vl-filename-directory fileSelect))
)
(initget "Yes No")
(setq cont? (getkword "\nAdd more paths? [Yes/No]<Yes>: "))
(if (= cont? "No")
(setq go nil)
(setq go T)
)
)
(progn
(alert "\nYou did not specify a directory to add.")
(setq go nil)
)
)
)
(if projPath
(vla-setProjectFilePath fileprefs projName projPath)
(alert "\nNo paths were specified.")
)
(princ)
)
;;;____________________________________________________________________________;;;
;;; ;;;
;;;Set up projects and XREF search paths. ;;;
;;;____________________________________________________________________________;;;
(defun c:Proj
(/ cmd acadapp prefs try_again go prevPath fileSelect cont?)
(vl-load-com)
(setq cmd (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq olderr *error*
*error* proj_error
projName nil
acadapp (vlax-get-acad-object)
prefs (vla-get-preferences acadapp)
fileprefs (vla-get-files prefs)
)
(while (not projName)
(setq eProjName (getvar "PROJECTNAME"))
(setq
projName
(getstring T
(strcat "\nNew Project Name <" eProjName ">:")
)
)
(if (= projName "")
(setq projName eProjName)
)
(if (or (= projName "")
(= projName " ")
(= projName "\"\"")
(= projName ".")
)
(progn
(alert "No Project Name has been specified.")
(initget "Yes No")
(setq try_again (getkword "\nTry again? [Yes/No]<Yes>: "))
(if (= try_again "No")
(setq go nil)
(setq projName nil)
)
)
(progn
(setq go T)
(setvar "PROJECTNAME" projName)
(setq projPath (vla-getProjectFilePath fileprefs projName))
(if (= projPath "")
(setq projPath nil)
)
)
)
)
(setq prevPath "\"\"")
(while go
(setq fileSelect
(getfiled
"Select a file within the directory to add (can be any file)."
prevPath
""
16
)
)
(if fileSelect
(progn
(setq prevPath (vl-filename-directory fileSelect))
(if projPath
(setq projPath (strcat projPath
";"
(vl-filename-directory fileSelect)
)
)
(setq projPath (vl-filename-directory fileSelect))
)
(initget "Yes No")
(setq cont? (getkword "\nAdd more paths? [Yes/No]<Yes>: "))
(if (= cont? "No")
(setq go nil)
(setq go T)
)
)
(progn
(alert "\nYou did not specify a directory to add.")
(setq go nil)
)
)
)
(if projPath
(vla-setProjectFilePath fileprefs projName projPath)
(alert "\nNo paths were specified.")
)
(setvar "cmdecho" cmd)
(setq *error* olderr)
(princ)
)