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

Running a command from a .vlx with a custom namespace from Autolisp

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
matthewbtaylor
903 Views, 7 Replies

Running a command from a .vlx with a custom namespace from Autolisp

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.

7 REPLIES 7
Message 2 of 8

Try to evaluate the function (c:commandname) instead.

--
Owen Wengerd
ManuSoft
Message 3 of 8

Works perfectly - so simple I didn't ecen think of it.

 

Many thanks.

Message 4 of 8

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?

Message 5 of 8
_gile
in reply to: matthewbtaylor

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.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 6 of 8
bhull1985
in reply to: _gile

(vl-load-com)

(setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))

(vla-sendcommand doc (strcat "C:yourcommand" "arg1" "arg2"))

 

may work for you?

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please use code tags and credit where credit is due. Accept as solution, if solved. Let's keep it trim people!
Message 7 of 8

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).

--
Owen Wengerd
ManuSoft
Message 8 of 8
matthewbtaylor
in reply to: bhull1985

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"))

 

 

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

Post to forums  

Autodesk Design & Make Report

”Boost