如何根据组名将组里的所有实体删除,以及清除组
AcDbDictionary *pGroupDict = NULL;Acad::ErrorStatus es;
acdbHostApplicationServices()->workingDatabase()->getGroupDictionary(pGroupDict,AcDb::kForWrite);
AcDbObjectId groupId;
es =pGroupDict->getAt("Test",groupId);
if (Acad::eOk == es)
{
pGroupDict->close();
}
AcDbGroup *pGroup = NULL;
es = acdbOpenObject(pGroup, groupId, AcDb::kForWrite);
if ( Acad::eOk == es)
{
AcDbObjectIdArray arrIds;
pGroup->allEntityIds(arrIds);//得到组中所有实体的ID
if (!arrIds.isEmpty())
{
AcDbEntity *pEnty = NULL;
Acad::ErrorStatus es;
int j;
for (j = 0; j < arrIds.length(); j++)
{
es = acdbOpenObject(pEnty, arrIds.at(j), AcDb::kForWrite);
if (Acad::eOk == es)
{
pEnty->erase();//删除组中包含的实体
pEnty->close();
}
}
}
pGroup->erase();//删除组
pGroup->close();
}
页:
[1]