CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2020 开发者帮助

与 AutoCAD 交互

2024-5-18 18:26| 发布者: admin| 查看: 99| 评论: 0|原作者: admin|来自: AutoCAD

与 AutoCAD 交互

从自动化上下文调用时,用户交互函数(如 )必须由一系列 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;
}

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1   苏公网安备32011402011833)

GMT+8, 2024-12-15 12:59

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部