Jump to content
M76

Commands vrom VLX in Lisp

Recommended Posts

M76

Hi

 

I'm trying to run a command inside a lisp, that is loaded from a vlx file into autocad. But it gives me an unkown command error. If I simply run it from the command line it works, but not through a lisp. Do I need to do something extra for the command to be avaialable from a lisp? I don't have access to the source of the vlx.

Share this post


Link to post
Share on other sites
VovKa
(c:your_command_here)

Share this post


Link to post
Share on other sites
M76

Thanks, now that I see it I remember there was something like this.

Share this post


Link to post
Share on other sites
M76

I don't get it, how do I pass parameters to the command this way?

Share this post


Link to post
Share on other sites
asos2000

upload the lisp

Share this post


Link to post
Share on other sites
Lee Mac

Depending on how it is written,

 

(your_command_here par1 par2 par3 ... parN)

Share this post


Link to post
Share on other sites
M76

No, I'm using a command from another file. (c:command) works, but that way I can't supply parameters.

Share this post


Link to post
Share on other sites
Lee Mac

So you are stuck with this construct?

 

[b][color=Blue](defun c:test (/ str)
 (setq str (getstring "\nEnter a String: "))
 (print str)
 (princ))[/color][/b]

(defun CallTest nil
[b][color=Red]  (c:test)[/color][/b]
 [b][color=Green](princ)[/color][/b])

This causes a problem as when the 'test' function is called (red), the blue code is evaluated, and the green code is not evaluated until the blue code is completed.

 

Lee

Share this post


Link to post
Share on other sites
alanjt

You're not giving a lot of information. However, it sounds like the vlx prompts for selection and a few questions.

 

What you could do is create your selection, then feed the selection and other required parameters to the routine through vla-sendcommand (I know I plug this command a lot).

 

eg.

 

ssget (no pickfirst)

(defun c:Test (/ ss)
 (if (setq ss (ssget "_:L"))
   (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "CommandName !ss Y N 0.5 ")))

ssget (with pickfirst available)

(defun c:Test (/ ss)
 (and (setq ss (ssget "_:L"))
      (sssetfirst nil ss)
      (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "CommandName Y N 0.5 ")))

entsel

(defun c:Test (/ e)
 (if (setq e (car (entsel)))
   (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object))
     "CommandName !e Y N 0.5 ")))

 

Oh yeah, and if in a situation where a space " " will not force the command to continue (ie: (getstring T "\nEnter String: ") ), you can replace the " " with "\n", which will act the same as if the user pressed the Enter key.

Share this post


Link to post
Share on other sites
Lee Mac

Nice idea Alan :thumbsup: I hadn't thought of using that :)

Share this post


Link to post
Share on other sites
alanjt
Nice idea Alan :thumbsup: I hadn't thought of using that :)

 

Thanks.

I'm not crazy about it, but it's probably the best course.:unsure:

Share this post


Link to post
Share on other sites
alanjt

I need to write a little explanation on using vla-sendcommand. I swear I mention/explain it and load/autoload all the time. LOL

Share this post


Link to post
Share on other sites
M76

Thanks for the tips, I ended up copying the command into the same lsp, and editing it to work as a function.

Share this post


Link to post
Share on other sites
alanjt
Thanks for the tips, I ended up copying the command into the same lsp, and editing it to work as a function.

 

'copying the command into the same lsp'

 

? :huh:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×