有的图看起来没多少实体,但是还是特别的大。
有可能是空的分组太多了,使用下面的方法
就可以极大的缩小源文件的大小,大大加快运行和渲染速度。
//清理空分组
//pDb,需要清理的数据库
Acad::ErrorStatus PurgeGroupDictionary(AcDbDatabase* pDb)
{
Acad::ErrorStatus es=Acad::eOk;
AcDbDictionary *pGroupDict;
es=pDb->getGroupDictionary(pGroupDict, AcDb::kForRead);
if(es!=Acad::eOk)
{
return es;
}
AcDbDictionaryIterator* pIter=pGroupDict->newIterator();
if(pIter==NULL)
{
pGroupDict->close();
return Acad::eNullHandle;
}
for(;!pIter->done();pIter->next())
{
AcDbObject* pObj=NULL;
if(Acad::eOk!=pIter->getObject(pObj,AcDb::kForWrite))
{
continue;
}
if(!pObj->isKindOf(AcDbGroup::desc()))
{
pObj->close();
continue;
}
AcDbGroup *pGroup=AcDbGroup::cast(pObj);
if(pGroup->numEntities()>0)
{
pObj->close();
continue;
}
acutPrintf(_T(“\r\n删除空分组:%s”),pIter->name());
pObj->erase();
pObj->close();
}
delete pIter;
pIter=NULL;
pGroupDict->close();
return Acad::eOk;
}