@My_Civil_3D wrote:
.... i have a lisp file that contains all my custom lisp functions .... i am trying to use the getenv to get the username of the pc, but i am unsure if you will be able to unload the lisp if the username doesnt match or a way for all the commands in the lisp file to not work?
Once the commands and functions defined in the AutoLisp file are loaded in the current session, I don't know of a way to unload them if you find the User is not on the authorized list. The User check would probably need to come before the loading. You probably need a different file that does something like:
(if (member (getenv "USERNAME") '("Bob" "Carol" "Ted" "Alice")); User name is among those authorized
(load ;;; then load your main file
EDIT: Another thought occurs to me, if for some reason it's awkward to do the above: You could have all the things defined in that file re-defined to be nothing if the User is not authorized:
(if (not (member (getenv "USERNAME") '("Bob" "Carol" "Ted" "Alice"))); User name is not among those authorized
(progn
(defun C:Command1 () ())
(defun function2 () ())
....
That way, you could have command and function definitions in the file that are available to all and also some in the same file available to a limited number of people, if the above re-defining-to-nothing only happens to those commands/functions you don't want available to everyone.
When I do that with some of my custom commands, if I type in the command name, I get nil returned, not an unknown-command message, so they're not really unloaded, but they wouldn't function.
But to me, it seems better to have them not loaded in the first place. Which could still be all within one file:
(if (member (getenv "USERNAME") '("Bob" "Carol" "Ted" "Alice")); User name is among those authorized
(progn ;;; then define limited-users commands/functions
(defun C:Command1 () (...define it...))
(defun function2 () (...define it...))
....
and define everybody-can-use commands/functions outside that (if) function.
Kent Cooper, AIA