|
- void ClearLayout()
- {
- CString msLayoutName;
- CStringArray layoutNames;
- AcDbObjectId msID = acdbSymUtil()->blockModelSpaceId(m采用pDatabase);
- AcDbObjectId dictId = m采用pDatabase->layoutDictionaryId();
- AcDbDictionary* pDict = NULL;
- if (Acad::eOk == acdbOpenObject(pDict, dictId, AcDb::kForWrite))
- {
- AcDbDictionaryIterator *iter = pDict->newIterator();
- for (; !iter->done(); iter->next())
- {
- AcDbObject* pDictObj = NULL;
- iter->getObject(pDictObj, AcDb::kForWrite);
- if (pDictObj->isKindOf(AcDbLayout::desc()))
- {
- AcDbLayout* pLayout = AcDbLayout::cast(pDictObj);
- AcDbObjectId blockTableRecordID = pLayout->getBlockTableRecordId();
- TCHAR *name = NULL;
- pLayout->getLayoutName(name);
- if (blockTableRecordID != msID)//属于模型空间的id
- {
- layoutNames.Add(name);
- }
- else
- {
- msLayoutName = name;
- }
- }
- pDictObj->close();
- }
- delete iter;
- iter = NULL;
- pDict->close();
- }
- //CAD不允许清理所有的布局[除开模型布局以外必须存在一个其他布局],创建一个临时的layout
- if (1)
- {
- AcDbObjectId layoutID, blockRecordID;
- acdbHostApplicationServices()->layoutManager()->createLayout(采用T("布局"), layoutID, blockRecordID, m采用pDatabase);
- }
- acdbHostApplicationServices()->layoutManager()->setCurrentLayout(msLayoutName, m采用pDatabase);
- for (int i = 0; i < layoutNames.GetSize(); i++)
- {
- Acad::ErrorStatus es = acdbHostApplicationServices()->layoutManager()->deleteLayout(layoutNames[i], m采用pDatabase);
- }
- }
复制代码 |
|