Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

load .LSP file named for windows login

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
dtiemeyer
488 Views, 5 Replies

load .LSP file named for windows login

If my windows login name is HSIMPSON and i have created HSIMPSON.lsp in a Supported Directory, how do I load that Lisp file via the command line?

 

I have tried:

(load "loginname")

 

but that doesn't work because the 'load' command seems to want an explicit name, not a variable name.

 

Any suggestions?

 

My other CAD is a Cadillac and I like to Revit to the Max!
5 REPLIES 5
Message 2 of 6
pbejse
in reply to: dtiemeyer

(load  (strcat (getvar "loginname") ".lsp") "Failed to Load")

 

Message 3 of 6
dtiemeyer
in reply to: pbejse

Thanks!

 

Just out of curiosity, what does the   "Failed to Load"  part do?

My other CAD is a Cadillac and I like to Revit to the Max!
Message 4 of 6
pbejse
in reply to: dtiemeyer

According to the help button:

 

Evaluates the AutoLISP expressions in a file

(load filename [onfailure])

 

onfailure

 

A value returned if load fails.

If the onfailure argument is a valid AutoLISP function, it is evaluated. In most cases, the onfailure argument should be a string or an atom. This allows an AutoLISP application calling load to take alternative action upon failure

 

Clear as mud eh? 🙂

 

HTH

 

 

Message 5 of 6
martti.halminen
in reply to: pbejse


@pbejse wrote:

According to the help button:

 

Evaluates the AutoLISP expressions in a file

(load filename [onfailure])

 

onfailure

 

A value returned if load fails.

If the onfailure argument is a valid AutoLISP function, it is evaluated. In most cases, the onfailure argument should be a string or an atom. This allows an AutoLISP application calling load to take alternative action upon failure

 


 

 

A little warning here, the document is somewhat unclear. LOAD is an ordinary function, so it lives under normal Lisp evaluation rules: all the arguments are evaluated before the function is called.

 

So, if you have a function in the onfailure argument, it is always called regardless of whether there is a failure or not. The only difference is that in the failure case its result is returned as the value of the LOAD call.

 

So

 

(load "foo.lsp" (alert "FOO!"))

 

would always produce the alert even if foo.lsp loaded with no problems.

 

There is no special evaluation behaviour for the onfailure argument: if you pass it an actual function, it is just returned as such with no additional evaluation:

 

_$ (load "C:/temp/roska.lsp" alert)
@#<SUBR @24c07ad8 ALERT>

 

 

--

 

 

Message 6 of 6
dtiemeyer
in reply to: martti.halminen

Thanks all. These responses are a little over my pay grade. But it's working, and thats what matters. Thanks!

My other CAD is a Cadillac and I like to Revit to the Max!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost