objectarx阻止cad命令

详见:
利用编辑反应器截获到命令后如何取消这个命令?
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) ;
}

猜你喜欢

转载自blog.csdn.net/tong794729500/article/details/79153083