用户交互函数(例如)在从自动化上下文调用时必须由一系列 ObjectARX API 调用包装。这些 ObjectARX 函数在交互之前保存 AutoCAD“状态”,并在交互之后恢复它。它们还确保在交互期间拒绝任何其他进程外自动化请求。这可以防止另一个自动化客户端在您等待用户输入时更改命令行或数据库。acedGetPoint() 与用户交互时要使用的 ObjectARX API 包括以下功能: Adesk::Boolean acedSetOLELock(int handle, int flags=0); Adesk::Boolean acedClearOLELock(int handle); void acedPostCommandPrompt(); 例如: // Get a point in AutoCAD, even though the point is not used. // STDMETHODIMP CMyApp::GetPoint() { // Establishing a lock informs AutoCAD to reject any other // out-of-process Automation requests. If this call is // made from an unknown context (e.g., not a normal AutoCAD // registered command or lisp), then it also saves the // current AutoCAD state. // if (acedSetOLELock(5) != Adesk::kTrue) // arbitrary handle value { return E_FAIL; } // Do the input acquisition (interaction). // ads_point result; if(acedGetPoint(NULL, "Pick a point: ", result) != RTNORM) { acedClearOLELock(5); return E_FAIL; } // Clear the lock to allow out-of-process Automation // requests to be accepted again. If the AutoCAD state was saved // during the call to acedSetOLELock(), then the saved state is // restored. // acedClearOLELock(5); // use same handle used in acedSetOLELock() // Forces AutoCAD to redisplay the command prompt. // acedPostCommandPrompt(); return S_OK; } |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-8 19:51
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.