You can define a command in your code that you invoke
with SendStringToExecute(), from the application context
(e.g., from the Click handler of a button on your palette).
The handler for that defined command will execute in the
document context, and you can access the command line
from there.
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com
"Stefano Costi" wrote in message news:5399470@discussion.autodesk.com...
Hi Tony, thanks for your answer.
I saw the file you linked looking in your other answers on this
newsgroup and I just tried it.
It works fine if I use it invoking the command through commandline.
My problem is that I created a PaletteSet and I added to it a simple
.net user control: it's made of 2 buttons and 1 textbox.
What I'd like to do is click on one button and run the command.
private void btnCreateLine_Click(object sender, EventArgs e)
{
CreateAcadLine(new Point3d(0, 0, 0), new Point3d(1000, 1000, 0));
}
Here is the definition of the CreateAcadLine method:
public static int CreateAcadLine(Point3d startPoint, Point3d endPoint)
{
return Command("._line", startPoint, endPoint, "");
}
where Command is the method that was in the file you linked.
If check the IsApplicationContext property it is always set to true.
I tried removing the check for the IsApplicationContext (I know, it's
stupid, but trying it's free 🙂 ), but simply nothing happens, the code
executes, but the line doesn't appears.
I tried other different methods, like using ads_queueexpr and other
unmanaged methods to send commands to autocad, obtaining no result.
The only working way I found is SendStringToExecute. I hate the way it
works, and if I could use acedCmd would be great. Is there anything I
can do to use it? Is there any way to change the context in which the
command is being executed (i.e. IsApplicationContext == false)?
Thanks again,
Stefano
Tony Tanzillo wrote:
> The simple answer is don't use SendStringToExecute()
> to start with.
>
> Instead of using SendStringToExecute, use acedCmd(),
> which you can p/invoke from C#.
>
> To see how, look at this file:
>
> http://www.caddzone.com/CommandLine.cs
>