- UID
- 512112
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2006-11-7
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
ObjectARX调用AUTOCAD内部命令方法大集合
<p>
ObjectARX
ads_queueexpr()
This old favourite is intended to be used from acrxEntryPoint() to execute a sequence of commands after (s::startup) has been called from LISP (as you are not able to use acedCommand() from this context)
You need to declare it yourself (extern "C" void ads_queueexpr( ACHAR *);) before use
It has been unsupported as long as I can remember, but is widely-used and mentioned in the Tips & Techniques section of the ObjectARX Developer's Guide
AcApDocManager::sendStringToExecute()
This Function has the advantage of a few more options being available as arguments, mainly around where to execute the string (which document, and whether it be activated), and whether to echo the string to the command-line
::SendMessage()
This is a standard Win32 platform API and so can, in effect, be used to drive AutoCAD from an external client. It uses a structure to pass the string that is often a bit tricky to set up (it became a migration issue when we switched to Unicode, for example)
IAcadDocument::SendCommand()
This COM method is the only way (other than acedCommand() or acedCmd()) to execute a command synchronously from AutoCAD (and even then it may not be completely synchronous if requiring user input)
acedCommand()
This is the ObjectARX equivalent to (command), and is genuinely synchronous. Unfortunately (as mentioned earlier) there are issues with using it directly from a natively-registered command, so I'd recommend only using it from acedDefun()-registered commands (see the ObjectARX documentation and the below sample for more details)
VBA (some of which also applies to VB)
ThisDrawing.SendCommand
This is the same as IAcadDocument::SendCommand() from C++
SendKeys
This is just a simple technique to send key-strokes to the command-line
SendMessage
This is just the Win32 API mentioned above, but declared and called from VB(A)
尽管有着相同的方法或者函数,但是不同的开发语言方法或者函数使用方式却不径相同,例如sendStringToExecute() ,在VB.NET中的用法是:
public void SendStringToExecute(
String command,
Boolean activate,
Boolean wrapUpInactiveDoc,
Boolean echoCommand
);
Parameterscommand String to use as input.
activate Boolean indicating whether to activate the target document.
wrapUpInactiveDoc Boolean indicating whether to queue current active document to complete in the next OnIdle() when switching active documents.
echoCommand Boolean indicating whether the sent string is echoed on the command line.
在C#中的用法又是这样的:
virtual Acad::ErrorStatus
sendStringToExecute(
AcApDocument* pAcTargetDocument,
const char * pszExecute,
bool bActivate = true,
bool bWrapUpInactiveDoc = false,
bool bEchoString = true) = 0;
pAcTargetDocument Document to send input to
pszExecute String to use as input
bActivate Boolean indicating whether to activate the target document
bWrapUpInactiveDoc Boolean indicating whether to queue current active document to complete in next OnIdle() when switching active documents.
bEchoString Boolean indicating whether the sent string is echoed on the command line
研究了一段时间的VB.NET与ObjectARX,发现VB.NET能用的函数或方法比VC++、C#要少一些,而且用法还不一样,有时就为一个函数就卡住了,真是叫人心急!
</p> |
|