Fortunately, in most offices, there is at least one common .lsp file that everyone has in their AutoCAD Startup Suite. If they don't, you can use yesterday's post as a guideline on how to add a .lsp file to everyone's Startup Suite using a batch file or a Windows-aware programming language (i.e. VBScript or PowerShell).
Once everyone has a common, network-based .lsp file in their Startup Suite, you can use this to your advantage and change its contents to do your bidding. For starters, you can use the code from yesterday's post to add additional items to users' Startup Suites.
Here are a few Lisp code snippets that will help you get started:
; Items in brackets [] are meant to be replaced with your specific values.
; If using any vlax functions:
(vl-load-com)
; A common task is to make sure a user has a certain directory in their support paths.
; The following snippet adds a given support directory to AutoCAD's support paths.
(setq suppdir "[YourSupportDir]")
(if (not (vl-string-search suppdir (getenv "ACAD")))
(setenv "ACAD" (strcat (vl-string-right-trim ";" (getenv "ACAD")) ";" suppdir))
)
(setq suppdir nil)
; If you want to explicitly set the support paths, just use (setenv "ACAD" "[SupportPathsHere]").
; The paths must be separated by semicolons.
; If your company uses a standard profile, you can use this snippet to make sure everyone uses it.
; Use yesterday's post to determine the current revision and version of AutoCAD and replace
; the x's with the correct values.
(vl-registry-write
"HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\Rxx.x\\ACAD-xxxx:xxx\\Profiles"
nil
"[YourDefaultProfile]"
)
; Say you want to make sure your users all have a certain tool palette.
(setq tooldir "[YourToolPaletteDirectory]"
toolpaths (vlax-get-property (vlax-get-property (vlax-get-property (vlax-get-acad-object) 'Preferences) 'Files) 'ToolPalettePath)
)
(if (not (vl-string-search tooldir toolpaths))
(vlax-put-property
(vlax-get-property (vlax-get-property (vlax-get-acad-object) 'Preferences) 'Files)
'ToolPalettePath
(strcat (vl-string-right-trim ";" toolpaths) ";" tooldir)
)
)
(setq tooldir nil toolpaths nil)
; If you want to disallow your users from having their own tool palettes, use this:
(vlax-put-property
(vlax-get-property (vlax-get-property (vlax-get-acad-object) 'Preferences) 'Files)
'ToolPalettePath
[ToolPalettePaths]
)
; These paths should also be separated by semicolons.
; Last but not least, if you want to do something for a specific user:
(if (= "johndoe" (getvar "LOGINNAME"))
; do stuff for John Doe
)
; You can modify the above snippet with an OR statement to do something for a group of users as well:
(if (or
(= "johndoe" (getvar "LOGINNAME"))
(= "janedoe" (getvar "LOGINNAME"))
)
; do stuff for the Does
)Enjoy, and as always comments are welcome.