找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1964|回复: 3

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

[复制链接]
发表于 2006-12-2 13:31:03 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
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>
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2006-12-2 16:08:39 | 显示全部楼层
C#和VB.net的方法是完全一样的,只是语法不同,这一点你说错的,所以你说的C#:virtual Acad::ErrorStatus
sendStringToExecute(
AcApDocument* pAcTargetDocument,
const char * pszExecute,
bool bActivate = true,
bool bWrapUpInactiveDoc = false,
bool bEchoString = true) = 0;

其实这是VC++的。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-12-4 13:16:12 | 显示全部楼层
看来是我搞错了。
VB.NET是和C#差不多,不过和VC++的差别比较大。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2006-12-4 14:25:35 | 显示全部楼层
下下来学习,谢谢楼主先
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-11-13 12:59 , Processed in 0.394915 second(s), 37 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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