Passing pressing "Enter" key for Commands

Passing pressing "Enter" key for Commands

Anonymous
Not applicable
4,253 Views
12 Replies
Message 1 of 13

Passing pressing "Enter" key for Commands

Anonymous
Not applicable

I am trying to use MATLAB to interface with AutoCAD by using ActiveX COM control. When I use "SendCommand" method to send commands to AutoCAD, I put space at the string's end " " to make it can be interpreted as "Enter". It works for most commands, but it does not work for "-PARAMETER" command.

 

"-PARAMETER" needs to make a selection  among [NEW EDIT RENAME DELETE]  options and it requires to press "Enter" key then. Space at the end does not work anymore. Does anyone have idea to solve this problem? 

 

It looks like someone using ".NET" control put "\n" at the end to pass "Enter" key, but it does not work here.

 

4,254 Views
12 Replies
Replies (12)
Message 2 of 13

lando7189
Advocate
Advocate

For the string as the 'command' argument use:

 

"-PARAMETER" & VbCr

 

- Lanny

Message 3 of 13

Anonymous
Not applicable
Hi, thank you for the reply. But if I understand correctly, the VbCr is
used in the .NET control? Currently I am using MATLAB to send commands like:

invoke(c_doc,"SendCommand","-PARAMETER E ");

I put VbCr at the string end like you mentioned, it does not work.

0 Likes
Message 4 of 13

Ranjit_Singh
Advisor
Advisor

@Anonymous wrote:
.....................
invoke(c_doc,"SendCommand","-PARAMETER E ");
.....................

What happens with

invoke(c_doc,"SendCommand","-PARAMETERS E\n");
0 Likes
Message 5 of 13

Anonymous
Not applicable

This is the AutoCAD Command Bar after receiving the command you ask.


0 Likes
Message 6 of 13

Ranjit_Singh
Advisor
Advisor

OK. How about now?

invoke(c_doc,"SendCommand","-PARAMETERS E test\n");
0 Likes
Message 7 of 13

Anonymous
Not applicable
Hi, it is the same but "\n" changes to "test\n".

My understanding is ActiveX is not very universal to AutoCAD, even though
it can support more programming language. But some commands are not
well-defined.

I properly need to switch to the .NET.....
0 Likes
Message 8 of 13

lando7189
Advocate
Advocate

Sorry earlier for the VB code.  .... can you try the following:

 

invoke(c_doc,"SendCommand","-PARAMETER" + newline + "E" + newline);

0 Likes
Message 9 of 13

divymital
Enthusiast
Enthusiast

Can you please suggest a way to press enter button through lisp.

0 Likes
Message 10 of 13

Kent1Cooper
Consultant
Consultant

@divymital wrote:

Can you please suggest a way to press enter button through lisp.


An empty text string, that is, two double-quote characters with nothing between them  ""  is Enter in AutoLisp (command) functions.  I'm not familiar with .NET, but if the original description in Message 1

    I put space at the string's end " " to make it can be interpreted as "Enter".

works in a given programming language, I would hope that "" would work for Enter [and not be "interpreted as" Enter].

Kent Cooper, AIA
0 Likes
Message 11 of 13

divymital
Enthusiast
Enthusiast

Hi.. Thanks for response ! We need to have the enter keyword press using lisp or activex functions. This is in order to kill a object arx popup by pressing enter keystoke.

0 Likes
Message 12 of 13

Kent1Cooper
Consultant
Consultant

@divymital wrote:

Hi.. Thanks for response ! We need to have the enter keyword press using lisp or activex functions. This is in order to kill a object arx popup by pressing enter keystoke.


I don't know that it will work if a popup is on-screen, because I'm not sure that will take input from an AutoLisp (command) function.  If you can suppress the popup and have whatever it is work from the command line, then the AutoLisp way to give it Enter would be:

  (command "")

or in many cases, simply

  (command)

with no arguments will cancel most things.

Kent Cooper, AIA
0 Likes
Message 13 of 13

phucquang
Observer
Observer

Can we do it by lisp?

0 Likes