I've got a command, which is run from a .vlx file (not created by myself).
Now, I want to automate this within an Autolisp script, to batch various operations together, however when I try it as (command "commandname") I get an error of Unknown Command.
From what I understand, this is because the routine in the .VLX file is using a different address space.
I've had a quick look, but drawn blanks - is there any way around this issue? It seems strange that I can just type in the command from the command line, but that it is impossible to call it from within Lisp.
Any thoughts would be welcomed.
Solved! Go to Solution.
Solved by owenwengerd. Go to Solution.
Try to evaluate the function (c:commandname) instead.
Oops - I spoke too soon. It works in terms of loading the command, but then falls down when it comes to passing options to it.
e.g. I start the command fine, but then it asks for various items & I can't pass these to it in the normal way.
Normally I might say:
(command ".commandname" "la")
Now, if I do it as
(c:commandname)
I can't see any way to pass these arguments to it.
I've tried adding them directly after it on the same line, or with (command "la") which doesn't work, as it won't let me re-enter lisp within the command.
Any thoughts?
Hi,
I think there's no way.
LISP functions prefixed with 'c:' can be called directly from the command line but aren't 'true commands' as the built-in ones or the custom ones defined with ObjectARX or .NET.
If the LISP function have been defined with none argument: (defun c:foo () ...), it can't be called with arguments.
The only way I see is to contact the VLX author to ge the source code.
(vl-load-com)
(setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
(vla-sendcommand doc (strcat "C:yourcommand" "arg1" "arg2"))
may work for you?
If there is no version of the function that accepts arguments, then you'll have to use something like vla-sendcommand as per bhull (except without the "C:" prefix in that case).
Thanks for this tip - finally got it to work with a slightly modified version of your suggestion. I also got stuck for a while with lines that would accept space, but eventually added a /r character after the expressions to simulate pressing enter & it seems to work properly now.
Many thanks
The final command arrangement that worked for me is:
(vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) (strcat "commandname " "input1 " "input2\r" "input3\r"))