Author Topic: Force load a profile from arg file at startup  (Read 5559 times)

0 Members and 1 Guest are viewing this topic.

strebor71

  • Guest
Force load a profile from arg file at startup
« on: April 24, 2015, 01:59:09 PM »
Hello peoples, I am wondering if there is a way to get autocad (2015) to load a profile from the .arg file each time a session is started. Instead of its normal if a profile name already exists load it from the registry behavior. For whatever reason we have a few people at the office whos profile settings will loose just the "support file search path" info for their profiles. All the other paths and settings do not get lost, ie. plotter support paths, template and trusted locations all are retained. Just two or three custom support paths, one of which is the location of our office wide accaddoc.lsp file which contains a whole list of custom commands. So at random times I get the "my commands aren't working again!" comment. SO I have to go change to a different profile delete the users profile and then load import the users .arg file and set it current to get the paths back, and restart autocad to get them going again. Its really getting old.

I would love to either have a lisp command that would do all of the above steps and have to run it when needed or better still, just have autocad load the profile from the arg file each time autocad is launched and prevent the profile problem all together.

Anyone else have this behavior with profiles?

ChrisCarlson

  • Guest
Re: Force load a profile from arg file at startup
« Reply #1 on: April 24, 2015, 02:03:07 PM »
We have this issue if the network isn't accessible when AutoCAD is loading. Is something similar happening to you?

strebor71

  • Guest
Re: Force load a profile from arg file at startup
« Reply #2 on: April 24, 2015, 02:35:51 PM »
No, it happens while the network is working fine. I have also put each users profile on their local machine, just so that if the network is down when they launch autocad their profile will always be found.

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
Re: Force load a profile from arg file at startup
« Reply #3 on: April 24, 2015, 02:48:21 PM »
The use of an "office wide accaddoc.lsp file" sounds a bit odd to me. Granted, it's been awhile since I have even looked at the AutoCAD icon on my desktop but I don't ever remember having to use something like that.

As far as the profile stuff goes, have a look through an old thread of mine.
http://www.theswamp.org/index.php?topic=14917.0

Not sure I can offer any sort of update or support for it's use anymore (if you wanted to customize it further) but I'm sure you can get someone to help if you need it.


TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

ChrisCarlson

  • Guest
Re: Force load a profile from arg file at startup
« Reply #4 on: April 24, 2015, 04:02:44 PM »
Or you create an enterprise CUI and load the applicable lisp routines. If it's a quite large .lsp file it could be taking some time to load which causes the file to lock, preventing someone else from loading it.

rkmcswain

  • Swamp Rat
  • Posts: 978
Re: Force load a profile from arg file at startup
« Reply #5 on: April 24, 2015, 05:26:07 PM »
Quote from: strebor71

I would love to either have a lisp command that would do all of the above steps and have to run it when needed .....


That is exactly how I've been handling it for over a decade now. We don't fool with "profiles" at all. Everything is simply "set" as needed at startup. Anything not "set" by the company startup files, the user is free to change (personal pref items). Many users elect to have me roll their personal preferences into their own personal startup lisp (which this system supports) and then if they get a new machine or have to go use a spare machine, virtually everything is set after they log on and startup AutoCAD.


strebor71

  • Guest
Re: Force load a profile from arg file at startup
« Reply #6 on: April 24, 2015, 05:39:06 PM »
I doubt the file is to large its only 5K.  Having a common accaddoc.lsp saves a whole lot of time on configuring a new system. simply install, copy over custom pgp, launch once, exit autocad, modify shortcut to include custom profile with path to accaddoc and and you just about done. I will have to experiment with a enterprise cui, I hadnt thought about using one. 

a question for seven on his profile loader, I cant seem to get your function to be its own runnable command. I added a c: to the defun but it errors with a too few arguments message.
Code: [Select]
(defun c:update-profile ( profile location / danames acd pro pre )
  ;; this will update a users profile
  ;;
  ;; Usage:
  ;; (update-profile "[ name ] " " [ path to ] ")
  ;; ...like:
  ;; (update-profile "Dumb" "c:\\StupidProfiles\\")
  ;;
  (vl-load-com)

  (setq acd (vlax-get-acad-object)
        pre (vla-get-preferences acd)
        pro (vla-get-profiles pre))

  (cond
    ((eq (getvar "CPROFILE") profile)
       (vla-getallprofilenames
         pro
         'danames)
       (setq danames (vlax-safearray->list danames))
       (vlax-put-property
         pro
         'ActiveProfile
         (if (eq (car danames) profile) (cadr danames) (car danames)))
       (update-profile "mike15" c:\\ACADtemp\\profile\\) )
   
    (t
        (vla-deleteprofile
          pro
          profile)
        ;; delete the prorile
        (vla-importprofile
          pro
          profile
          (strcat location profile ".arg")
          :vlax-true)
        (vlax-put-property
          pro
          'ActiveProfile
          profile))
    )
  )

accaddoc.lsp file
Code: [Select]
;;;MWA Custom Programs************************************

;THESE LISP FILES CAN BE FOUND in S:\ACAD Support\LSP


;[Message]^C^C(if (not C:message) (load "message"));message LOADS THIS PROGRAM AUTOMATICALLY if no semicolin

(autoload "webb-trees" '("webb-trees"));replaces webb tree blocks with MWA's

(autoload "ucszoom" '("uZ"));adjusts ucs per selection

(autoload "ddshapes" '("ddshapes")); steel shapes library

(autoload "dofix" '("dofix"));draw order fix routine

(autoload "archdo" '("archdo"));draw order fix routine for arch base

(autoload "ssfix" '("ssfix"));MWA sheet set, page layout replace

(autoload "hd" '("hd"));true horizontal distance

(autoload "LL" '("ll"));draws lines at bearing and distance

(autoload "AUTOFLAT" '("AUTOFLAT"))

(autoload "mwapsetups" '("mwapsetups"))

(autoload "2ML" '("2ML"))

(autoload "exp" '("exp"));Starts windows explorer in current directory

(autoload "VPXLF" '("VPXLF"));Freeze layer in current viewport

(autoload "XLF" '("XLF"));Freeze XREF Layer

(autoload "XLO" '("XLO"));Turn off XREF Layer

(autoload "Xil" '("Xil"));Isolate XREF Layer

(autoload "LAYS" '("LF"));WILL FREEZE SELECTED LAYER

(autoload "LAYS" '("LO"));TURNS LAYER OFF

(autoload "LAYS" '("LS"));SETS PICKED ITEM'S LAYER CURRENT

(autoload "sla" '("sla"));slope arrow





;------------------COMMANDS FOR ELV2 LSP----------------
(autoload "elv2" '("NT"))
(autoload "elv2" '("ST"))
(autoload "elv2" '("ET"))
(autoload "elv2" '("WT"))
(autoload "elv2" '("NW"))
(autoload "elv2" '("NE"))
(autoload "elv2" '("SE"))
(autoload "elv2" '("SW"))
(autoload "elv2" '("NW2"))
(autoload "elv2" '("NE2"))
(autoload "elv2" '("SE2"))
(autoload "elv2" '("SW2"))
(autoload "elv2" '("NW3"))
(autoload "elv2" '("NE3"))
(autoload "elv2" '("SE3"))
(autoload "elv2" '("NE44"))
(autoload "elv2" '("SE44"))
(autoload "elv2" '("NW44"))
(autoload "elv2" '("SW44"))
(autoload "elv2" '("NW45"))
(autoload "elv2" '("NE45"))
(autoload "elv2" '("SE45"))
(autoload "elv2" '("SW45"))
(autoload "elv2" '("NE62"))
(autoload "elv2" '("SE62"))
(autoload "elv2" '("NW62"))
(autoload "elv2" '("SW62"))
(autoload "elv2" '("NE64"))
(autoload "elv2" '("SE64"))
(autoload "elv2" '("NW64"))
(autoload "elv2" '("SW64"))
(autoload "elv2" '("NE84"))
(autoload "elv2" '("SE84"))
(autoload "elv2" '("NW84"))
(autoload "elv2" '("SW84"))
(autoload "elv2" '("PL1"))
(autoload "elv2" '("PL2"))
(autoload "elv2" '("PL3"))
(autoload "elv2" '("PL4"))
(autoload "elv2" '("PL5"))
(autoload "elv2" '("PL6"))
(autoload "elv2" '("GAR"))
(autoload "elv2" '("SITE"))
(autoload "elv2" '("SCA"))
(autoload "elv2" '("SCB"))
(autoload "elv2" '("SCC"))
(autoload "elv2" '("SCD"))
(autoload "elv2" '("SCE"))
(autoload "elv2" '("SCF"))
(autoload "elv2" '("SCG"))
(autoload "elv2" '("SCH"))
(autoload "elv2" '("SCJ"))
(autoload "elv2" '("SCK"))
(autoload "elv2" '("HID1"))
(autoload "elv2" '("HID2"))
(autoload "elv2" '("HID3"))
(autoload "elv2" '("HID4"))
;-------------------END ELV2 LSP --------------------
;------------------LEVELS2 LSP --------------------
(autoload "levels2" '("A1"))
(autoload "levels2" '("A2"))
(autoload "levels2" '("A3"))
(autoload "levels2" '("ELC1"))
(autoload "levels2" '("ELC2"))
(autoload "levels2" '("ELC3"))
(autoload "levels2" '("SITEL"))
(autoload "levels2" '("RFOFF"))
(autoload "levels2" '("RP"))
(autoload "levels2" '("RPCLR"))
(autoload "levels2" '("STCP"))
(autoload "levels2" '("TON"))
(autoload "levels2" '("TPS"))
(autoload "levels2" '("ELON"))
(autoload "levels2" '("ELOFF"))
(autoload "levels2" '("ON"))
(autoload "levels2" '("OA"))
(autoload "levels2" '("FA"))
(autoload "levels2" '("TA"))
(autoload "levels2" '("OFF"))
;----------------------END----------------

(autoload "win" '("win"))
(autoload "win" '("wintrim"))
(autoload "win" '("DOOR"))
(autoload "win" '("DOORTRIM"))
(autoload "DVTW" '("DTW"))
(autoload "DVTW" '("DTW0"))
(autoload "DVTW" '("DTWR"))
(autoload "DVTW" '("TWT"))








(autoload "flatten" '("flatten"))

(autoload "half" '("half"))



(defun C:Lsp ()
(setvar "CMDECHO" 0)
(setq TXTa (getstring "\nENTER NAME OF LISP ROUTINE TO LOAD:   "))
(LOAD TXTa)
(setq TXTp (strcat "\n" TXTa " HAS BEEN LOADED......  "))
(setvar "CMDECHO" 1)
(prompt TXTp)
(princ)
)

;"ld" lenthen dynamic   
(defun c:lgd () (command "lengthen" "dy") (princ))
;"le" lenthen delta   
(defun c:lge () (command "lengthen" "de") (princ))
;"lt" lenthen total   
(defun c:lgt () (command "lengthen" "t") (princ))

(princ)

(LOAD "DOFIX")
(if (tblsearch "block" "rundofix")
  (c:dofix)
(princ)
)

(setvar "hpmaxlines" 10000000)

(defun MWAStartup ()
(command "._purge" "r" "*" "_n") ;;purge regapps
(command "HPMAXAREAS" 0)
(command "-scalelistedit" "_r" "_y" "_e");;reset scale list
(graphscr)
)
(if S::STARTUP
(setq S::STARTUP (append S::STARTUP '((MWAStartup)) ))
(defun s::startup ( ) (MWAStartup) )
)





strebor71

  • Guest
Re: Force load a profile from arg file at startup
« Reply #7 on: April 24, 2015, 05:43:14 PM »
Quote from: strebor71

I would love to either have a lisp command that would do all of the above steps and have to run it when needed .....


That is exactly how I've been handling it for over a decade now. We don't fool with "profiles" at all. Everything is simply "set" as needed at startup. Anything not "set" by the company startup files, the user is free to change (personal pref items). Many users elect to have me roll their personal preferences into their own personal startup lisp (which this system supports) and then if they get a new machine or have to go use a spare machine, virtually everything is set after they log on and startup AutoCAD.


So what are the company startup files you speak of? dont you need a profile to set the proper paths to load the company statrup files?

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
Re: Force load a profile from arg file at startup
« Reply #8 on: April 25, 2015, 08:43:32 AM »
I doubt the file is to large its only 5K.  Having a common accaddoc.lsp saves a whole lot of time on configuring a new system. simply install, copy over custom pgp, launch once, exit autocad, modify shortcut to include custom profile with path to accaddoc and and you just about done. I will have to experiment with a enterprise cui, I hadnt thought about using one. 

a question for seven on his profile loader, I cant seem to get your function to be its own runnable command. I added a c: to the defun but it errors with a too few arguments message.
Code: [Select]
(defun c:update-profile ( profile location / danames acd pro pre )
  ;; this will update a users profile
  ;;
  ;; Usage:
  ;; (update-profile "[ name ] " " [ path to ] ")
  ;; ...like:
  ;; (update-profile "Dumb" "c:\\StupidProfiles\\")
  ;;
  (vl-load-com)

  (setq acd (vlax-get-acad-object)
        pre (vla-get-preferences acd)
        pro (vla-get-profiles pre))

  (cond
    ((eq (getvar "CPROFILE") profile)
       (vla-getallprofilenames
         pro
         'danames)
       (setq danames (vlax-safearray->list danames))
       (vlax-put-property
         pro
         'ActiveProfile
         (if (eq (car danames) profile) (cadr danames) (car danames)))
       (update-profile "mike15" c:\\ACADtemp\\profile\\) )
   
    (t
        (vla-deleteprofile
          pro
          profile)
        ;; delete the prorile
        (vla-importprofile
          pro
          profile
          (strcat location profile ".arg")
          :vlax-true)
        (vlax-put-property
          pro
          'ActiveProfile
          profile))
    )
  )

accaddoc.lsp file
Code: [Select]
;;;MWA Custom Programs************************************

;THESE LISP FILES CAN BE FOUND in S:\ACAD Support\LSP


;[Message]^C^C(if (not C:message) (load "message"));message LOADS THIS PROGRAM AUTOMATICALLY if no semicolin

(autoload "webb-trees" '("webb-trees"));replaces webb tree blocks with MWA's

(autoload "ucszoom" '("uZ"));adjusts ucs per selection

(autoload "ddshapes" '("ddshapes")); steel shapes library

(autoload "dofix" '("dofix"));draw order fix routine

(autoload "archdo" '("archdo"));draw order fix routine for arch base

(autoload "ssfix" '("ssfix"));MWA sheet set, page layout replace

(autoload "hd" '("hd"));true horizontal distance

(autoload "LL" '("ll"));draws lines at bearing and distance

(autoload "AUTOFLAT" '("AUTOFLAT"))

(autoload "mwapsetups" '("mwapsetups"))

(autoload "2ML" '("2ML"))

(autoload "exp" '("exp"));Starts windows explorer in current directory

(autoload "VPXLF" '("VPXLF"));Freeze layer in current viewport

(autoload "XLF" '("XLF"));Freeze XREF Layer

(autoload "XLO" '("XLO"));Turn off XREF Layer

(autoload "Xil" '("Xil"));Isolate XREF Layer

(autoload "LAYS" '("LF"));WILL FREEZE SELECTED LAYER

(autoload "LAYS" '("LO"));TURNS LAYER OFF

(autoload "LAYS" '("LS"));SETS PICKED ITEM'S LAYER CURRENT

(autoload "sla" '("sla"));slope arrow





;------------------COMMANDS FOR ELV2 LSP----------------
(autoload "elv2" '("NT"))
(autoload "elv2" '("ST"))
(autoload "elv2" '("ET"))
(autoload "elv2" '("WT"))
(autoload "elv2" '("NW"))
(autoload "elv2" '("NE"))
(autoload "elv2" '("SE"))
(autoload "elv2" '("SW"))
(autoload "elv2" '("NW2"))
(autoload "elv2" '("NE2"))
(autoload "elv2" '("SE2"))
(autoload "elv2" '("SW2"))
(autoload "elv2" '("NW3"))
(autoload "elv2" '("NE3"))
(autoload "elv2" '("SE3"))
(autoload "elv2" '("NE44"))
(autoload "elv2" '("SE44"))
(autoload "elv2" '("NW44"))
(autoload "elv2" '("SW44"))
(autoload "elv2" '("NW45"))
(autoload "elv2" '("NE45"))
(autoload "elv2" '("SE45"))
(autoload "elv2" '("SW45"))
(autoload "elv2" '("NE62"))
(autoload "elv2" '("SE62"))
(autoload "elv2" '("NW62"))
(autoload "elv2" '("SW62"))
(autoload "elv2" '("NE64"))
(autoload "elv2" '("SE64"))
(autoload "elv2" '("NW64"))
(autoload "elv2" '("SW64"))
(autoload "elv2" '("NE84"))
(autoload "elv2" '("SE84"))
(autoload "elv2" '("NW84"))
(autoload "elv2" '("SW84"))
(autoload "elv2" '("PL1"))
(autoload "elv2" '("PL2"))
(autoload "elv2" '("PL3"))
(autoload "elv2" '("PL4"))
(autoload "elv2" '("PL5"))
(autoload "elv2" '("PL6"))
(autoload "elv2" '("GAR"))
(autoload "elv2" '("SITE"))
(autoload "elv2" '("SCA"))
(autoload "elv2" '("SCB"))
(autoload "elv2" '("SCC"))
(autoload "elv2" '("SCD"))
(autoload "elv2" '("SCE"))
(autoload "elv2" '("SCF"))
(autoload "elv2" '("SCG"))
(autoload "elv2" '("SCH"))
(autoload "elv2" '("SCJ"))
(autoload "elv2" '("SCK"))
(autoload "elv2" '("HID1"))
(autoload "elv2" '("HID2"))
(autoload "elv2" '("HID3"))
(autoload "elv2" '("HID4"))
;-------------------END ELV2 LSP --------------------
;------------------LEVELS2 LSP --------------------
(autoload "levels2" '("A1"))
(autoload "levels2" '("A2"))
(autoload "levels2" '("A3"))
(autoload "levels2" '("ELC1"))
(autoload "levels2" '("ELC2"))
(autoload "levels2" '("ELC3"))
(autoload "levels2" '("SITEL"))
(autoload "levels2" '("RFOFF"))
(autoload "levels2" '("RP"))
(autoload "levels2" '("RPCLR"))
(autoload "levels2" '("STCP"))
(autoload "levels2" '("TON"))
(autoload "levels2" '("TPS"))
(autoload "levels2" '("ELON"))
(autoload "levels2" '("ELOFF"))
(autoload "levels2" '("ON"))
(autoload "levels2" '("OA"))
(autoload "levels2" '("FA"))
(autoload "levels2" '("TA"))
(autoload "levels2" '("OFF"))
;----------------------END----------------

(autoload "win" '("win"))
(autoload "win" '("wintrim"))
(autoload "win" '("DOOR"))
(autoload "win" '("DOORTRIM"))
(autoload "DVTW" '("DTW"))
(autoload "DVTW" '("DTW0"))
(autoload "DVTW" '("DTWR"))
(autoload "DVTW" '("TWT"))








(autoload "flatten" '("flatten"))

(autoload "half" '("half"))



(defun C:Lsp ()
(setvar "CMDECHO" 0)
(setq TXTa (getstring "\nENTER NAME OF LISP ROUTINE TO LOAD:   "))
(LOAD TXTa)
(setq TXTp (strcat "\n" TXTa " HAS BEEN LOADED......  "))
(setvar "CMDECHO" 1)
(prompt TXTp)
(princ)
)

;"ld" lenthen dynamic   
(defun c:lgd () (command "lengthen" "dy") (princ))
;"le" lenthen delta   
(defun c:lge () (command "lengthen" "de") (princ))
;"lt" lenthen total   
(defun c:lgt () (command "lengthen" "t") (princ))

(princ)

(LOAD "DOFIX")
(if (tblsearch "block" "rundofix")
  (c:dofix)
(princ)
)

(setvar "hpmaxlines" 10000000)

(defun MWAStartup ()
(command "._purge" "r" "*" "_n") ;;purge regapps
(command "HPMAXAREAS" 0)
(command "-scalelistedit" "_r" "_y" "_e");;reset scale list
(graphscr)
)
(if S::STARTUP
(setq S::STARTUP (append S::STARTUP '((MWAStartup)) ))
(defun s::startup ( ) (MWAStartup) )
)





Strebor71, I tell you how you can make a callable function in the comments of that function. Also, someone else, in that thread, asked and I helped them (please read the thread I linked to) back then.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
Re: Force load a profile from arg file at startup
« Reply #9 on: April 27, 2015, 10:04:44 AM »
When I got into work today I launched AutoCAD (first time in years) and tried to make a "callable function" for you. This is what I came up with. Hope it helps.

Someone with more lisp experience can help us clean this hack up (one thing we're good at here is help and other ideas).
Code - Auto/Visual Lisp: [Select]
  1. (defun c:Update-My-Profile ( / )
  2.   (cond
  3.     ((vl-symbol-value 'UPDATE-PROFILE)
  4.          (princ "\nUpdating profile...")
  5.          (update-profile "Dumb" "c:\\StupidProfiles\\") ;; <-- Your stuff goes here.
  6.          (princ "\nProfile updated.") )
  7.      (T
  8.        (alert "Please Load the support procedure \"UPDATE-PROFILE\" or contact the administrator for help." )) )
  9.   )
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Crank

  • Water Moccasin
  • Posts: 1503
Re: Force load a profile from arg file at startup
« Reply #10 on: April 27, 2015, 11:33:15 AM »
Wy use lisp? If you use lisp then first the profile from the registry will be loaded and after that you replace it with another!

It's faster, cleaner and easier if you edit the startup icon (see help).
If the .arg-file is on a protected location on your network drive, then users also don't loose the 'support file search path' if the network (temporary) isn't accessible.
Vault Professional 2023     +     AEC Collection

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Force load a profile from arg file at startup
« Reply #11 on: April 27, 2015, 01:02:15 PM »
Quote from: strebor71

I would love to either have a lisp command that would do all of the above steps and have to run it when needed .....


That is exactly how I've been handling it for over a decade now. We don't fool with "profiles" at all. Everything is simply "set" as needed at startup. Anything not "set" by the company startup files, the user is free to change (personal pref items). Many users elect to have me roll their personal preferences into their own personal startup lisp (which this system supports) and then if they get a new machine or have to go use a spare machine, virtually everything is set after they log on and startup AutoCAD.

+1, except we do have profiles and use the names to manage groups of settings including support file search paths.  The only way for the core system to not load is for the user to be buggering about with the settings on their own.  As a little added insurance I have a local ACAD.LSP file which exits AutoCAD if it's found first.

So what are the company startup files you speak of? dont you need a profile to set the proper paths to load the company statrup files?

That's only needed for the very first run, and even then not entirely necessary to use an ARG file.  I automate a merge from a central REG file, for example.  After that the automation takes over management of the search paths.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}