CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ObjectARX 开发指南

与 AutoCAD 交互

2022-12-31 12:35| 发布者: admin| 查看: 487| 评论: 0|来自: 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 )

GMT+8, 2024-5-19 14:59

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部