robbin 发表于 2006-12-2 11:55:00

[函数]ARX调用AUTOCAD内部命令方法大集合

<DIV style="FONT-SIZE: 12px"><B><B>ObjectARX</B>调用AUTOCAD内部命令方法大集合</B> <BR><BR><B>ObjectARX</B><BR></DIV>
<DIV style="FONT-SIZE: 12px">
<UL>
<LI>ads_queueexpr()
<UL>
<LI>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)
<LI>You need to declare it yourself (<FONT color=blue>extern</FONT> <FONT color=maroon>"C"</FONT> <FONT color=blue>void</FONT> ads_queueexpr( ACHAR *);) before use
<LI>It has been unsupported as long as I can remember, but is widely-used and mentioned in the Tips &amp; Techniques section of the ObjectARX Developer's Guide</LI></UL>
<OL></OL>
<LI>AcApDocManager::sendStringToExecute()
<UL>
<LI>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</LI></UL>
<OL></OL>
<LI>::SendMessage()
<UL>
<LI>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)</LI></UL>
<OL></OL>
<LI>IAcadDocument::SendCommand()
<UL>
<LI>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)</LI></UL>
<OL></OL>
<LI>acedCommand()
<UL>
<LI>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)</LI></UL>
<OL></OL></LI></UL></DIV>
<OL></OL><B>VBA (some of which also applies to VB)</B><BR>
<UL>
<LI>ThisDrawing.SendCommand
<UL>
<LI>This is the same as IAcadDocument::SendCommand() from C++</LI></UL>
<OL></OL>
<LI>SendKeys
<UL>
<LI>This is just a simple technique to send key-strokes to the command-line</LI></UL>
<OL></OL>
<LI>SendMessage
<UL>
<LI>This is just the Win32 API mentioned above, but declared and called from VB(A)</LI></UL>
<OL></OL></LI></UL>
<OL></OL>
<P>&nbsp; &nbsp; 尽管有着相同的方法或者函数,但是不同的开发语言方法或者函数使用方式却不径相同,例如sendStringToExecute() ,在VB.NET中的用法是:<BR>public <FONT color=#0000ff>void</FONT> SendStringToExecute(<BR>&nbsp; &nbsp;<FONT color=#0000ff>String</FONT> command,<BR>&nbsp; &nbsp;<FONT color=#0000ff>Boolean</FONT> activate,<BR>&nbsp; &nbsp;<FONT color=#0000ff>Boolean</FONT> wrapUpInactiveDoc,<BR>&nbsp; &nbsp;<FONT color=#0000ff>Boolean</FONT> echoCommand<BR>);<BR>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. <BR><BR>在C#中的用法又是这样的:<BR>virtual Acad::ErrorStatus<BR>sendStringToExecute(<BR>AcApDocument* pAcTargetDocument,<BR>const char * pszExecute,<BR>bool bActivate = true,<BR>bool bWrapUpInactiveDoc = false,<BR><FONT size=2>bool bEchoString = true) = 0;</FONT> </P>
<P>pAcTargetDocument Document to send input to <BR>pszExecute String to use as input <BR>bActivate&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Boolean indicating whether to activate the target document <BR>bWrapUpInactiveDoc Boolean indicating whether to queue current active document to complete in next OnIdle() when switching active documents. <BR>bEchoString&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Boolean indicating whether the sent string is echoed on the command line</P>
<P>研究了一段时间的VB.NET与ObjectARX,发现VB.NET能用的函数或方法比VC++、C#要少一些,而且用法还不一样,有时就为一个函数就卡住了,真是叫人心急。</P>

wangfen_feng 发表于 2008-7-31 13:32:00

是啊!!!!急!!!
页: [1]
查看完整版本: [函数]ARX调用AUTOCAD内部命令方法大集合