明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 6356|回复: 1

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

[复制链接]
发表于 2006-12-2 11:55 | 显示全部楼层 |阅读模式
ObjectARX调用AutoCAD内部命令方法大集合

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
    1. 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
      1. ::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)
        1. 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)
          1. 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++
                1. SendKeys
                  • This is just a simple technique to send key-strokes to the command-line
                  1. 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#要少一些,而且用法还不一样,有时就为一个函数就卡住了,真是叫人心急。

                      发表于 2008-7-31 13:32 | 显示全部楼层
                      是啊!!!!急!!!
                      您需要登录后才可以回帖 登录 | 注册

                      本版积分规则

                      小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
                      ©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

                      GMT+8, 2024-5-5 10:48 , Processed in 0.160003 second(s), 23 queries , Gzip On.

                      Powered by Discuz! X3.4

                      Copyright © 2001-2021, Tencent Cloud.

                      快速回复 返回顶部 返回列表