- UID
- 1
- 积分
- 16111
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-3
- 最后登录
- 1970-1-1
|
发表于 2002-9-27 18:32:25
|
显示全部楼层
贴篇资料,关于如何在ARX里面使用ads_command()

- [FONT=courier new]
- Using ads_command() and ads_invoke() in ARX
- ID 1945
- Applies to: AutoCAD
- AutoCAD 2000I
- AutoCAD R14
- Question
- I encountered some problems when using ads_command or ads_invoke() from an ARX
- command or from within the acrxEntryPoint() function. Why ?
- Answer
- ads_command() works in two basic contexts in ADS: when operating on the RQXLOAD
- and RQSUBR request codes. In ARX however, it is not working for the ARX app
- message AcRx::kLoadDwgMsg, which is the ARX equivalent of RQXLOAD. It works fine
- for the message AcRx::kInvkSubr, which is equivalent to RQSUBR.
- kLoadDwgMsg workaround: 'int ads_queueexpr(char* lisp_expr);'
- Since it is important to many applications to be able to execute a few AutoCAD
- commands at the beginning of every drawing edit session, this can be
- accomplished by queuing up LISP expressions, including use of the (COMMAND)
- function, using ads_queueexpr(), for execution during the edit session
- initialization, after (S::STARTUP) has been executed.
- Note that the queued expressions are *not* executed during the call to
- ads_queueexpr(); they will occur after your application has returned from its
- kLoadDwgMsg message invocation of acrxEntryPoint(). When using ads_queueexpr(),
- the entered string must be fully expanded and with outer parentheses. Whatever
- was previously passed in as resbuf chains must be converted to ASCII to use this
- mechanism. Multiple calls to ads_queueexpr() from the kLoadDwgMsg callback is
- acceptable because they are queued up in the order of the calls.
- extern "C" void ads_queueexpr (char *) ;
- void MyArxFunc () {
- //----- Here I should better not use ads_command()
- }
- int MyFunc () {
- //----- Here I can use ads_command()
- }
- extern "C" AcRx::AppRetCode acrxEntryPoint (AcRx::AppMsgCode msg, void *p) {
- switch ( msg ) {
- case AcRx::kInitAppMsg:
- acrxUnlockApplication (p) ;
- acedRegCmds->addCommand ("TEST_GROUP", "MyArxFunc",
- "MyArxFunc", ACRX_CMD_MODAL, MyArxFunc) ;
- // ...
- break ;
- case AcRx::kUnloadAppMsg:
- acedRegCmds->removeGroup ("TEST_GROUP") ;
- // ...
- break ;
- case AcRx::kLoadDwgMsg:
- ads_defun ("C:MYFUNC", 0) ;
- //----- Here I can use ads_command(), instead use
- ads_queueexpr()
- ads_queueexpr ("(command "line" "0,0,0" "10,10,0"
- "")") ;
- break ;
- case AcRx::kInvkSubrMsg:
- if ( ads_getfuncode () == 0 )
- MyFunc () ;
- break ;
- }
- return (AcRx::kRetOK) ;
- }
- [/FONT]
|
|