- UID
- 2299
- 积分
- 465
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-31
- 最后登录
- 1970-1-1
|
发表于 2003-7-11 00:16:42
|
显示全部楼层
Re: [求助]:调用CAD系统命令后如何取得其命令执行完的信息?(有图片和代码)
最初由 Echoyin 发布
[B][CODE]
//调用CAD系统命令函数
void SendCommandToAcad(CString cmd)
{
HWND hAcad=adsw_acadMainWnd();
if(!hAcad) return ;
COPYDATASTRUCT cmdMsg;
cmdMsg.dwData=(DWORD)1;
... [/B]
在ApplicationContext中,你的SendCommandToAcad()函数以及acedCommand() 和 sendStringToExecute()都会以异步的方式执行Acad命令( 就是你说的这种情况).
然而,你可以利用AutoCAD Automation API 提供的'SendCommand'方法来同步执行.(翻译太累,直接看英文吧)
Question
How can I call a command from the application context synchronously? acedCommand
seems to work properly from the document context but it does not work in the
application context.
Answer
See DevNote #35993. If you want to call a built-in AutoCAD command from the
application context, use the sendStringToExecute API. Note that this API is
asynchronous in a sense that the Sent command won't be executed until the
current message handler returns.
However, the AutoCAD Automation API provides another method 'SendCommand' that
immediately executes the sent command when called from the application context.
However, if the command you send to AutoCAD prompts the user for any input, the
Sent command may not fully execute, particularly if SendCommand is not invoked
at the end of an ARX function. In this degenerate case, the command string will
be output on the command line, but not all prompts will be issued (as in the
case of an AutoLISP expression) and the program will move on to executing any
lines of code following the call to SendCommand.
If your application needs to execute some code when an interactive command
finishes, you should consider moving that code to the commandEnded() reactor
notification. Do not place any lines of code in a function after the call to
SendCommand as this will prematurely terminate the command execution.
The attached sample shows how to use Automation API to execute the LINE command
synchronously from a modeless dialog. |
|