objectarx阻止cad命令

本文介绍了一种在AutoCAD中阻止特定命令执行的方法,通过使用AcApDocManagerReactor类的documentLockModeChanged()回调函数,并在其中调用veto()方法来实现。这种方法可以有效地阻止如SAVEAS等命令的执行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

详见:
利用编辑反应器截获到命令后如何取消这个命令?
http://bbs.xdcad.net/thread-706107-1-1.html
(出处: 晓东CAD家园-论坛)

你要阻止一个内部的ACAD命令执行,需要在AcApDocManagerReactor::documentLockModeChanged()期间,用veto()方法,除了终止,你甚至还可以创建一个你自己的SAVEAS等等。

AcApDocManagerReactor::veto Function
Acad::ErrorStatus
veto();
This function can be called during a documentLockModeChanged() callback if it is a callback for a lock request. The result will be that the lock request will be vetoed, which normally means that the command will be cancelled before it can start. When this function is called, documentLockModeChangeVetoed() will be sent.
If this is called during any other callback, or during an unlock request, it returns eNotApplicable.
It is only active during documentLockModeChanged() in case the receiver of the call needs to make any changes in the document before deciding whether to veto or not. By waiting until the changed callback, the document will be currently locked when the ability to veto is given. This is necessary because it is not possible to change the document抯 lock status from within any of these callbacks.

void Stop::documentLockModeChanged(AcApDocument * param2, AcAp::DocLockMode myPreviousMode, AcAp::DocLockMode myCurrentMode, AcAp::DocLockMode currentMode, const ACHAR * pGlobalCmdName)
{
  if (_tcscmp(pGlobalCmdName,_T("QSAVE")) == 0 || _tcscmp(pGlobalCmdName,_T("SAVEAS"))==0)
  {
    if(...)//判断是否需要取消保存或者另存为命令
    {
        acutPrintf(_T("\n禁止保存或另存为操作!\n"));
        Acad::ErrorStatus es = veto();
    }
  }
  AcApDocManagerReactor::documentLockModeChanged (param2, myPreviousMode, myCurrentMode, currentMode, pGlobalCmdName) ;
}
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值