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

AcadDocument.SendCommand

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
4879 Views, 5 Replies

AcadDocument.SendCommand

Good afternoon, I'm writing an application with C#2008 that need to send -ETransmit command via SendCommand API using AcadDocument.
This is what I do:

string progID = "AutoCAD.Application.18";
Type acType = Type.GetTypeFromProgID(progID);
acApp = (AcadApplication)Activator.CreateInstance(acType, true);

acApp.ActiveDocument.SendCommand("-estransmit\r");
acApp.ActiveDocument.SendCommand("C");
acApp.ActiveDocument.SendCommand("MyZIPFilePath\r");
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

Good afternoon, I'm writing an application with C#2008 that need to send -ETransmit command via SendCommand API using AcadDocument.
This is what I do:

string progID = "AutoCAD.Application.18";
Type acType = Type.GetTypeFromProgID(progID);
acApp = (AcadApplication)Activator.CreateInstance(acType, true);

acApp.ActiveDocument.SendCommand("-estransmit\r");
acApp.ActiveDocument.SendCommand("C");
acApp.ActiveDocument.SendCommand("MyZIPFilePath\r");

Everything works fine when the firt SendCommand is executed, but when it try to execute the others an exception is raised HRESULT: 0x80010001 (RPC_E_CALL_REJECTED). I tried to add a WaitTime beetween each SendCommand, but I got the exception as well. I know this issue is due to a "time" propblem, but I can't figure out how to solve it. Any ideas?

Thanks in advance
Marco
Message 3 of 6
Anonymous
in reply to: Anonymous

Have you tried sending everything in a single call to SendCommand() ?

SendCommand("-ETRANSMIT\nC\nMyZIPFilePath\n");

You can separate the response to each input prompt with a newline ("\n").

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6286282@discussion.autodesk.com...
Good afternoon, I'm writing an application with C#2008 that need to
send -ETransmit command via SendCommand API using AcadDocument.
This is what I do:

string progID = "AutoCAD.Application.18";
Type acType = Type.GetTypeFromProgID(progID);
acApp = (AcadApplication)Activator.CreateInstance(acType, true);

acApp.ActiveDocument.SendCommand("-estransmit\r");
acApp.ActiveDocument.SendCommand("C");
acApp.ActiveDocument.SendCommand("MyZIPFilePath\r");

Everything works fine when the firt SendCommand is executed, but when it try
to execute the others an exception is raised HRESULT: 0x80010001
(RPC_E_CALL_REJECTED). I tried to add a WaitTime beetween each SendCommand,
but I got the exception as well. I know this issue is due to a "time"
propblem, but I can't figure out how to solve it. Any ideas?

Thanks in advance
Marco
Message 4 of 6
Anonymous
in reply to: Anonymous

Hi, thanks for your help!

> Have you tried sending everything in a single call to SendCommand() ?
>SendCommand("-ETRANSMIT\nC\nMyZIPFilePath\n");
>You can separate the response to each input prompt with a newline ("\n").
Yes I did, but it doesn't work as expected every time. Sometimes the command works fine and AutoCAD generate MyZIPFilePath file, but other times I found AutoCAD waiting for a command, sometimes waiting for "C" parameter, sometimes waiting for the path.

I think this is due to a time issue because it seems that C# is faster than AutoCAD, so I splitted ETransmit in three different commands. "Googling" around the net, I found a tip inside Microsoft Site (MSDN) that explain the problem and suggest a possibile solution using a static class that implement IOleMessageFilter interface.

Link:
http://msdn.microsoft.com/en-us/library/ms228772(VS.80).aspx.

Using this class I solve the problem but when the application send the second command nothing happen. Both application (AutoCAD + C# application) are still working but AutoCAD didn't receive the command and C# application didn't get any exception.
I need to send ETransmit via SendCommand because I must automate this operation in order to decrease our drawing time. Maybe you know a "shortcut" to do ETransmit in way I don't know, but in the future I'm sure I will need to use SendCommand maybe with "multiple" send commands, so I want to resolve the problem using this way...

Thanks again
Marco
Message 5 of 6
PeterKelec3372
in reply to: Anonymous

I would try to combine the message like Tony suggested:

SendCommand("-ETRANSMIT\nC\nMyZIPFilePath\n");

If you do not combine the message, the first SendCommand starts the "-etransmit" command and is waiting for additional input. While waiting, you cannot use the SendCommand function again (it will be rejected).

Just an idea, the second step of the "-etransmit" command brings up a dialog box. Maybe that is the source of your problem. Try changing the FILEDIA system variable to 0 before running the combined command "-ETRANSMIT\nC\nMyZIPFilePath\n".
Message 6 of 6
Anonymous
in reply to: Anonymous

Hi, thanks for your help!

>Just an idea, the second step of the "-etransmit" command brings up a dialog box. Maybe that is the source of your problem.
>Try changing the FILEDIA system variable to 0 before running the combined command "-ETRANSMIT\nC\nMyZIPFilePath\n".

Yes!!!! Your suggestion solved my problem. Setting FILEDIA == 0 when I send the full command everything work EVER as expected.
Thank you very much for your precious help.

Kind regards
Marco

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

Post to forums  

Forma Design Contest


Autodesk Design & Make Report