Hi!! I found this lisp that loads a users profile based on the login name. I don't know who wrote this, but it work nice. The only problem is if I uncomment the following line (which should reload the profile):
(vlax-invoke-method acadProfiles 'ResetProfile profilename)
it seems to have revert back to a default profile. Can someone explain to me what I did wrong? Thanks
;CODING STARTS HERE
(prompt "\nType LoginProfile to run......")
(vl-load-com)
(defun C:LoginProfile (/ profilename acadprofiles actprofile
thelist profilepath)
;retrieve the users login name
(setq profilename (strcase (getvar "LOGINNAME")))
;retrieve a reference to the Profiles
(setq acadprofiles (vla-get-profiles
(vla-get-preferences (vlax-get-Acad-Object))))
;retrieve the Active Profile
(setq actprofile (strcase (vla-get-ActiveProfile acadprofiles)))
;if they are not the same
(if (/= profilename actprofile)
;do the following
(progn
;get a list of the loaded profiles
(vlax-invoke-method acadProfiles 'GetAllProfileNames 'thelist)
;convert to a list
(setq thelist (vlax-safearray->list thelist))
;if the profile is not in the list
(if (not (member profilename thelist))
;do the following
(progn
;store the profile file
(setq profilepath
(strcat "c:/profiles/" profilename ".arg"))
;if the profile is found
(if (findfile profilepath)
;do the following
(progn
;load the profile
(setq NewProfile (vlax-invoke-method
acadprofiles 'ImportProfile
profilename profilepath :vlax-true))
;make the profile the Active Profile
(vla-put-ActiveProfile acadProfiles profilename)
);progn
;profile file cannot be found - exit
(prompt (strcat "\nCannot find profile " profilepath))
);if
);progn
;it is loaded but make the profile the Active Profile
(vla-put-ActiveProfile acadProfiles profilename)
);if
);progn
;Uncomment the next line to reload the Profile.
;(vlax-invoke-method acadProfiles 'ResetProfile profilename)
);if
(princ)
);defun
(princ)
;CODING ENDS HERE