static void sk_ARXTestXDatamydimassoc(void)
{
// Add your code for command sk_ARXTestXData.mydimassoc here
ads_name ent;
ads_point pt;
if (RTNORM != acedEntSel(_T("\n请选择标注:"),ent,pt))
{
return;
}
AcDbObjectId objId=AcDbObjectId::kNull;
acdbGetObjectId(objId,ent);
//智能指针打开
AcDbObjectPointer<AcDbDimension> pDim(objId,AcDb::kForRead);
if (Acad::eOk != pDim.openStatus())
{
return;
}
void* pSomething;
AcDbObjectReactor* pObjReactor;
AcDbObject* obj;
Acad::ErrorStatus es;
es= pDim->upgradeOpen();
if (es!= Acad::eOk)
{
return;
}
const AcDbVoidPtrArray* reactors = pDim->reactors();
if (reactors == nullptr)
return;
for (int i = 0; i < reactors->length(); i++)
{
pSomething = reactors->at(i);
if (!acdbIsPersistentReactor(pSomething))
{
continue;
}
//永久反应器
AcDbObjectId persReactorId=acdbPersistentReactorObjectId(pSomething);
//智能指针打开对象
AcDbObjectPointer<AcDbObject> obj(persReactorId,AcDb::kForRead);
//es = acdbOpenObject(obj,persReactorId , AcDb::kForRead);
if ((obj.openStatus() == Acad::eOk) && obj)
{
CString str;
str.Format(_T("%s"),obj->isA()->name());
if (str == _T("AcDbDimAssoc"))
{
acutPrintf(str);
obj->upgradeOpen();
obj->erase();
//移除永久反应器
pDim->removePersistentReactor(persReactorId);
}
//obj->close();
}
}
//释放删除反应器的空字典
pDim->releaseExtensionDictionary();
}