Passing point to command and getting results programmatically using c#

Passing point to command and getting results programmatically using c#

Anonymous
Not applicable
714 Views
3 Replies
Message 1 of 4

Passing point to command and getting results programmatically using c#

Anonymous
Not applicable

Dear all.

 

I want to call the command(e.g. LABCOOR or LABLAT) programmatically using:

doc.SendStringToExecute("LABLAT\n", false, false, false);

or 

ed.Command("LABLAT");

or any other way.

Running this command requires user to pick a point. Is there a way to automate point selection?

And other question: is there a way to get results of a command programmatically as well?

 

Is that correct approach at all?

My problem in general: get lat/long values of a point to handle them later.

 

Thanks in advance.

0 Likes
Accepted solutions (1)
715 Views
3 Replies
Replies (3)
Message 2 of 4

_gile
Consultant
Consultant
Accepted solution

@Anonymous wrote:

Dear all.

 

I want to call the command(e.g. LABCOOR or LABLAT) programmatically using:

doc.SendStringToExecute("LABLAT\n", false, false, false);

or 

ed.Command("LABLAT");

or any other way.

Running this command requires user to pick a point. Is there a way to automate point selection?


Assuming the point is (20, 10,0)

doc.SendStringToExecute("LABLAT 20,10,0\n", false, false, false); 
//or
ed.Command("LABLAT", new Point3d(20.0, 10.0, 0.0));

@Anonymous wrote:

And other question: is there a way to get results of a command programmatically as well?


A command cannot return a value but you can store some value in a member of your class.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 4

Anonymous
Not applicable

@_gile wrote:


Assuming the point is (20, 10,0)

doc.SendStringToExecute("LABLAT 20,10,0\n", false, false, false); 
//or
ed.Command("LABLAT", new Point3d(20.0, 10.0, 0.0));

@Anonymous wrote:

And other question: is there a way to get results of a command programmatically as well?


A command cannot return a value but you can store some value in a member of your class.


Thanks for your reply!
So, that means that I could pass point coordinates to a command. But how do I get it's results? I mean not on the plot, but programmatically?
I guess I could look for newly added elements and get text values there, but I feel that there should be a better way to do it.

0 Likes
Message 4 of 4

_gile
Consultant
Consultant

A method decored with the CommandMethod attribute cannot have arguments and cannot return a value.

So you have to use a work around with some side effect to "get the command results".

As said before, you can have some member (field or property) in the class where the command is defined and set their values from the command method.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes