View Full Version : Check from which directory a *.DWG opens from...

20th Jan 2011, 09:20 am
Dear all,

To automatically switch profiles at startup I want to create a script that "looks" from which directory a *.DWG drawing is opened from. This detection script runs directly when AutoCAD starts up.

If the user opens a drawing from c:\tek\ then "profile_one" has to be selected, and if the user opens a drawing from every other directory then "profile_two" must be selected.

Please can you help me to "detect" from which directory a drawing is opened.

Thanks in advance!!

With kind regards,

(from the Netherlands, so excuses my English)

21st Jan 2011, 02:40 am
(setq answer (getvar "dwgprefix"))

plus a "startup" lsp to change profile

24th Jan 2011, 03:39 pm
Thanks for the reply!

In the meanwhile I've had it working with VBA...


if Mid$(GeopendDocument, 1, 7) = "C:\tek\" then... else... end if


With kind regards,


24th Jan 2011, 04:51 pm
(defun c:FOO (/ *profs* pNames profNameList myProfName)
(if (and
(setq *profs* (vla-get-profiles
(vla-get-preferences (vlax-get-acad-object))))
(vla-getallprofilenames *profs* 'pNames)
(setq profNameList (vlax-safearray->list pNames))
(vl-string-search "C:\\TEK\\" (strcase (getvar 'dwgprefix))))
(setq myProfName "PROFILE_ONE")
(setq myProfName "PROFILE_TWO"))
(if (vl-position myProfName profNameList)
(vla-put-activeprofile *profs* myProfName)
(prompt (strcat "\n >> Profile \"" myProfName "\" Has Been made Active! ")))
(prompt (strcat "\n <!> Profile \"" myProfName "\" Cannot Be Found <!> ")))

:: Untested ::

Hope this helps!