Author Topic: Profiles  (Read 2593 times)

0 Members and 1 Guest are viewing this topic.

CADwoman

  • Guest
Profiles
« on: February 10, 2005, 02:51:24 PM »
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

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Profiles
« Reply #1 on: February 11, 2005, 07:52:58 AM »
What is the name of the  "default profile" ?

I ran the code and it worked so I'm a little :?
TheSwamp.org  (serving the CAD community since 2003)

CADwoman

  • Guest
Profiles
« Reply #2 on: February 14, 2005, 02:37:03 PM »
Thanks for responding to my question. The default profile is <<Unnamed Profile>>. But as far as I understand, since it loads the profile that matches your login (which I have) then shouldn't it reload the same profile?
Quote from: Mark Thomas
What is the name of the  "default profile" ?

I ran the code and it worked so I'm a little :?