void ExportGraphs(TCHAR * path)
{
wchar_t szConturTemplateName[MAX_PATH];
wcscpy(szConturTemplateName , _T("d:\\ConturBuildingTemplate.dwg"));
/*Чертеж контура объекта*/
AcDbDatabase *pConturDB = new AcDbDatabase(Adesk::kFalse);
if(Acad::eOk != pConturDB->readDwgFile(szConturTemplateName , _SH_DENYNO))
{
delete pConturDB;
acutPrintf(_T("Ошибка при открытии шаблона\n"));
return;
}
/*Указатель на оригинальную базу (файл)*/
AcDbDatabase *pOriginDB = acdbHostApplicationServices()->workingDatabase();
/*Центруем шаблон и выставляем масштаб*/
acdbHostApplicationServices()->setWorkingDatabase(pConturDB);
AcDbBlockTable * ConturBlockTable;
if(Acad::eOk != pConturDB->getBlockTable(ConturBlockTable , AcDb::kForRead))
{
delete pConturDB;
acutPrintf(_T("Ошибка при getBlockTable\n"));
return;
}
AcDbBlockTableIterator *ConturBlockTableIterator;
if(Acad::eOk != ConturBlockTable->newIterator(ConturBlockTableIterator , true , true))
{
ConturBlockTable->close();
delete pConturDB;
acutPrintf(_T("Ошибка при newIterator\n"));
return;
}
for (ConturBlockTableIterator->start(); !ConturBlockTableIterator->done(); ConturBlockTableIterator->step())
{
AcDbBlockTableRecord *ConturBlockTableRecord;
if(Acad::eOk != ConturBlockTableIterator->getRecord(ConturBlockTableRecord,AcDb::kForRead))
{
delete ConturBlockTableIterator;
ConturBlockTable->close();
delete pConturDB;
acutPrintf(_T("Ошибка при ConturBlockTableIterator->getRecord\n"));
return;
}
if(ConturBlockTableRecord->isLayout() != Adesk::kFalse)
{
AcDbObjectId idLayout = ConturBlockTableRecord->getLayoutId();
AcDbLayout * pLayout;
if(Acad::eOk != acdbOpenObject(pLayout,idLayout,AcDb::kForRead))
{
ConturBlockTableRecord->close();
delete ConturBlockTableIterator;
ConturBlockTable->close();
delete pConturDB;
acutPrintf(_T("Ошибка при acdbOpenObject\n"));
return;
}
ACHAR *pLayName;
pLayout->getLayoutName(pLayName);
if(wstring(pLayName) == wstring(_T("Схема")))
{
AcDbObjectIdArray ViewPortIdArray;
ViewPortIdArray.append(pLayout->getViewportArray());
AcDbObjectId ViewPortId = ViewPortIdArray.at(0);
}
pLayout->close();
}
ConturBlockTableRecord->close();
}
delete ConturBlockTableIterator;
ConturBlockTable->close();
acdbHostApplicationServices()->setWorkingDatabase(pOriginDB);
/*Формируем имя результирующего файла*/
wstring wsConturFileName(path);
wsConturFileName.append(_T("\\contur.dwg"));
CString sConturFileName(wsConturFileName.c_str());
/*Сохраним результат*/
pConturDB->saveAs(sConturFileName.GetBuffer());
delete pConturDB;
}