.NET

Reply
*ST
Message 1 of 5 (340 Views)

Passing an entity through SendStringToExecute

340 Views, 4 Replies
11-16-2006 04:36 AM
Hi all.
I'm trying to run an Autocad command through SendStringToExecute method
of Document class.
The command I'm trying to run requires, first of all, that you select an
object on the drawing.
Now I'm using Autodesk.AutoCAD.Internal.Utils.SelectObjects to select an
object on the drawing and then run SendStringToExecute to execute the
comand. It work's fine, but it has promlems when I repeat this procedure
multiple times in a row. It is due to the lack of synchronization
between commands executed in Autocad and .NET commands.
Is there any way to pass to an Autocad command the object it needs?
The command I'm, trying to use is aecwindowadd, it's an Architectural
Desktop command, but it works the same as any other Autocad command:
first it asks you to select an object, then ask for a point. If you
select the object before running the command it asks you only for the point.
I'd like to do something like

(command "aecwindowadd" "wall1" "point")

or in alternative, first run an Autocad command to automatically select
the wall and then run the windowadd command.
Thank you all,

Stefano
*Tony Tanzillo
Message 2 of 5 (340 Views)

Re: Passing an entity through SendStringToExecute

11-16-2006 01:44 PM in reply to: *ST
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

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

"ST@N" wrote in message news:5397914@discussion.autodesk.com...
Hi all.
I'm trying to run an Autocad command through SendStringToExecute method
of Document class.
The command I'm trying to run requires, first of all, that you select an
object on the drawing.
Now I'm using Autodesk.AutoCAD.Internal.Utils.SelectObjects to select an
object on the drawing and then run SendStringToExecute to execute the
comand. It work's fine, but it has promlems when I repeat this procedure
multiple times in a row. It is due to the lack of synchronization
between commands executed in Autocad and .NET commands.
Is there any way to pass to an Autocad command the object it needs?
The command I'm, trying to use is aecwindowadd, it's an Architectural
Desktop command, but it works the same as any other Autocad command:
first it asks you to select an object, then ask for a point. If you
select the object before running the command it asks you only for the point.
I'd like to do something like

(command "aecwindowadd" "wall1" "point")

or in alternative, first run an Autocad command to automatically select
the wall and then run the windowadd command.
Thank you all,

Stefano
*Stefano Costi
Message 3 of 5 (340 Views)

Re: Passing an entity through SendStringToExecute

11-17-2006 03:41 AM in reply to: *ST
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 :smileyhappy: ), 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
>
*Tony Tanzillo
Message 4 of 5 (340 Views)

Re: Passing an entity through SendStringToExecute

11-17-2006 02:26 PM in reply to: *ST
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 :smileyhappy: ), 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
>
*Stefano Costi
Message 5 of 5 (340 Views)

Re: Passing an entity through SendStringToExecute

11-21-2006 11:32 PM in reply to: *ST
Hi Tony,
I've done what you've suggested and it work's great.
It's exactly what i needed.

Thank you very much :smileyhappy:

Stefano


Tony Tanzillo wrote:
> 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.
>
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.