Jump to content

Running lsp or vlx from acaddoc.lsp


Recommended Posts

Posted

I'm sure this is really simple but I'm having problems.

I want to run 'lockallvp.vlx' every time i open a file.

I am currently using acaddoc as follows:

(load "lockallvp.vlx")

lockallvp

 

The plugin loads but does not run.

Thanks for your help

Aaron

Posted

Use:

 

(if (load "lockallvp.vlx" nil)
   (c:lockallvp)
   (princ "\nFailed to Load lockallvp.vlx")
)

 

Or, with slightly more error trapping:

 

(if (and (load "lockallvp.vlx" nil) c:lockallvp)
   (c:lockallvp)
   (princ "\nFailed to Load lockallvp.vlx")
)

 

Welcome to the forum :)

Posted

Thanks Lee. it appears your second example runs the function more than once. Is there are reason the 'if' statement wouldn't inherently perform the function during the test?

e.g.

 

(if (and (load "lockallvp.vlx" nil) c:lockallvp)

(princ "\nlockallvp.vlx loaded and successfully executed")

(princ "\nFailed to Load lockallvp.vlx")

)

Posted
Thanks Lee. it appears your second example runs the function more than once. Is there are reason the 'if' statement wouldn't inherently perform the function during the test?

e.g.

 

(if (and (load "lockallvp.vlx" nil) c:lockallvp)

(princ "\nlockallvp.vlx loaded and successfully executed")

(princ "\nFailed to Load lockallvp.vlx")

)

 

c:lockallvp invoked via LISP will not execute without the necessary parenthesis, like so: (c:lockallvp).

 

If the function is being executed at load, that is because the author of the VLX add the above mentioned call at the end of their function definition.

 

Another simple example:

 

(defun c:HelloWorld () ; <-- Define function
 (prompt "\nHello World! ")
 (princ))
(c:HelloWorld ) ; <-- Autorun function

Posted
Also, please remember to use
. :thumbsup:

 

[color=white].........................................[/color]

Posted
Thanks Lee. it appears your second example runs the function more than once. Is there are reason the 'if' statement wouldn't inherently perform the function during the test?

e.g.

 

(if (and (load "lockallvp.vlx" nil) c:lockallvp)

(princ "\nlockallvp.vlx loaded and successfully executed")

(princ "\nFailed to Load lockallvp.vlx")

)

 

Perhaps that author included a call to the function within the vlx application, as Renderman suggests.

 

As for:

 

(if c:lockallvp
   (do_something)
   (else_do_something)
)

The function c:lockallvp is not being evaluated, I am simply testing the symbol 'c:lockallvp' to see whether a functional value has been bound to it; i.e. whether the symbol evaluates to something non-nil.

 

As an example:

 

_$ (defun c:LeeMac ( ) (princ "\nThis is a function."))
C:LEEMAC
_$ 
_$ c:LeeMac
#<USUBR @1755cb7c C:LEEMAC>   ;; <--- Value of symbol 'c:LeeMac' (pointer to c:LeeMac Function Definition)

Posted

Lee, I believe this is the sample the OP is suggesting invokes the c:LockAllVp twice:

 

(if (and ([color=blue]load "lockallvp.vlx" nil[/color]) c:lockallvp)
 ([color=blue]c:lockallvp[/color])
 (princ "\nFailed to Load lockallvp.vlx")
)

 

** Edit - Again, presuming that the VLX includes a call at load.

Posted

I thought the OP was confused as to why 'c:lockallvp' appeared in the AND statement, so provided a brief explanation - as you rightly suggest, my guess is that the lockallvp command runs when loaded.

Posted

Thanks gents that was all incredibly informative.

Lee is right, I assumed the mention of lockallvp in the 'and' statement was running the function, but apparently it is just checking for the definition?

Posted
Thanks gents that was all incredibly informative.

Lee is right, I assumed the mention of lockallvp in the 'and' statement was running the function, but apparently it is just checking for the definition?

 

You are correct; more specifically when the AND statement passes (non-nil), the THEN portion of the IF statement is what invokes the command a second time (the LOAD being the first).

Posted

Thanks RenderMan I understand the structure.

It is sad what time and an unrelated degree can do to my soft. eng. undergrad., particularly when I was doing ai in lisp. Tisk.

Really appreciate the solid feedback. Hope I can give back some time.

Posted
Thanks RenderMan I understand the structure.

It is sad what time and an unrelated degree can do to my soft. eng. undergrad., particularly when I was doing ai in lisp. Tisk.

Really appreciate the solid feedback. Hope I can give back some time.

 

Now that you mention it....using CODE TAGS would be a big help.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...