CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ObjectARX 开发指南

获取对象反应器的 ID

2022-12-31 19:58| 发布者: admin| 查看: 309| 评论: 0|来自: AutoCAD

每个数据库对象都维护一个反应器列表。有些是瞬态反应堆,有些是持久性的。瞬态反应器是派生自的类的实例,而持久反应器是数据库驻留对象的对象 ID。AcDbObjectReactor

以下代码演示如何搜索反应器列表以查找瞬态或持久性反应器。通过使用函数验证反应器列表中的特定条目是否为持久性反应器非常重要。如果是持久反应器,则可以使用相应的函数来获取其对象 ID。如果它不是持久性反应器,则可以将条目转换为。AcDbIsPersistentReactor()AcDbObjectReactor

AcDbVoidPtrArray *pReactors;
void             *pSomething;
AcDbObjectReactor *pObjReactor;
AcDbObjectId       persObjId;
AcDbObject        *pPersReacObj;
pReactors = pEnt->reactors();
if (pReactors != NULL && pReactors->length() > 0) {
    for (int i = 0; i < pReactors->length(); i++) {
        pSomething = pReactors->at(i);
        // Is it a persistent reactor?
        //
        if (acdbIsPersistentReactor(pSomething)) {
            persObjId = acdbPersistentReactorObjectId(
                pSomething);
            acutPrintf("\n\nPersistent reactor found.");
            // Echo the keyname to the user.
            //
            char *keyname = NULL;
            getPersReactorKey(keyname, persObjId);
            if (keyname) {
                acutPrintf("\nThis is the reactor named %s",
                keyname);
                free (keyname);
            }
            // Open it up and see if it's one of ours. If it is,
            // fire the custom notification.
            //
            if ((retStat =
                acdbOpenAcDbObject(pPersReacObj,
                persObjId, AcDb::kForNotify))
                != Acad::eOk)
            {
                acutPrintf("\nFailure for"
                    " openAcDbObject: retStat==%d\n",
                    retStat);
                return;
            }
            AsdkPersReactor *pTmpPers;
            if ((pTmpPers =
                AsdkPersReactor::cast((AcRxObject*)
                pPersReacObj)) != NULL)
            {
                pTmpPers->custom();
            }
            pPersReacObj->close(); 
        } else {
            // Or is it transient?
            //
            pObjReactor = (AcDbObjectReactor *)
                          (pReactors->at(i));
            acutPrintf("\n\nTransient Reactor found");
            // Report what kind we found.
            //
            if (pObjReactor->isKindOf(
                AsdkSimpleObjReactor::desc()))
            {
                acutPrintf(" of type"
                    " AsdkSimpleObjReactor");
            } else if (pObjReactor->isKindOf(
                AcDbEntityReactor::desc()))
            {
                acutPrintf(" of type"
                    " AcDbEntityReactor");
            } else if (pObjReactor->isKindOf(
                AcDbObjectReactor::desc()))
            {
                acutPrintf(" of type"
                    " AcDbObjectReactor");
            } else {
                acutPrintf(" of unknown type.");
            }
        }
    }
} else {
    acutPrintf("\nThis entity has no reactors.\n");
}

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-19 12:24

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部