TA的每日心情![](source/plugin/dsu_paulsign/img/emot/kx.gif) | 开心 昨天 15:23 |
---|
签到天数: 69 天 [LV.6]常住居民II
管理员
- 积分
- 2704
|
[code]bool SelectEntity(LPCWSTR prompt, AcDbObjectId &objid)
{
ads_point pt;
ads_name ename;
if (acedEntSel(prompt, ename, pt) != RTNORM)
return false;
return (acdbGetObjectId(objid, ename) == Acad::eOk);
}
void cmdTestConnectPersistReactor()
{
AcDbObjectId idCar, idEngine, idLine;
if (!SelectEntity(L"\nSelect car: ", idCar))
return;
if (!SelectEntity(L"\nSelect engine: ", idEngine))
return;
if (!SelectEntity(L"\nSelect connection line: ", idLine))
return;
Acad::ErrorStatus es;
AcDbEntity *pLine;
if ((es = acdbOpenObject(pLine, idLine, AcDb::kForWrite)) == Acad::eOk)
{
pLine->addPersistentReactor(idCar);
pLine->addPersistentReactor(idEngine);
pLine->close();
}
}
void cmdPrintReactors()
{
AcDbObjectId idLine;
if (!SelectEntity(L"\nSelect connection line: ", idLine))
return;
Acad::ErrorStatus es;
AcDbEntity *pLine;
const AcDbVoidPtrArray *reactors = nullptr;
if ((es = acdbOpenObject(pLine, idLine, AcDb::kForRead)) == Acad::eOk)
{
reactors = pLine->reactors();
pLine->close();
}
if (reactors)
{
void* pSomething = 0;
for (int j = 0; j < reactors->length(); j++)
{
void *pSomething = reactors->at(j);
if (acdbIsPersistentReactor(pSomething))
{
AcDbObjectId objId = acdbPersistentReactorObjectId(pSomething);
AcDbObject *pObj;
if ((es = acdbOpenObject(pObj, objId, AcDb::kForRead)) == Acad::eOk)
{
LPCTSTR className = pObj->isA()->name();
acutPrintf(L"\nFound a reactor of class %s", className);
pObj->close();
}
}
}
}
}[/code] |
|