获取对象反应器的 ID
每个数据库对象都维护一个反应器列表。有些是瞬态反应堆,有些是持久的。瞬态反应器是派生自 的类的实例,而持久反应器是驻留在数据库中的对象的对象 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");
}
父主题: |
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-11-3 02:31
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.