.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Passing an entity through SendStringToExecute

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
1343 Views, 4 Replies

Passing an entity through SendStringToExecute

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
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

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
Message 3 of 5
Anonymous
in reply to: Anonymous

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
>
Message 4 of 5
Anonymous
in reply to: Anonymous

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
>
Message 5 of 5
Anonymous
in reply to: Anonymous

Hi Tony,
I've done what you've suggested and it work's great.
It's exactly what i needed.

Thank you very much 🙂

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

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost