一个McDbLayout对象储存每个图纸空间布局的属性。布局对象储存在McDbLayoutDictionary对象中,允许简单的遍历和索引
class McDbLayout : public McDbPlotSettings;
McDbLayout.h
例如:得到控件所有的布局函数
bool GetAllLayoutName(McDbDatabase* pDatabase, std::vector<CString>& allLayoutName) { if(pDatabase == NULL) { if(Mx::mcdbHostApplicationServices() != NULL) pDatabase = Mx::mcdbHostApplicationServices()->workingDatabase(); } if(pDatabase == NULL) { return false; } McDbDictionary* pDict = NULL; if(pDatabase->getLayoutDictionary(pDict,McDb::kForRead) != Mcad::eOk) { return false; } McDbDictionaryIterator* pIter = pDict->newIterator(); for(;!pIter->done();pIter->next() ) { McDbObjectPointer<McDbLayout> spLayout(pIter->objectId(),McDb::kForRead); if(spLayout.openStatus() != Mcad::eOk) continue; LPCTSTR pszLayoutName = NULL; spLayout->getLayoutName(pszLayoutName); CString sTmpLayoutName(pszLayoutName); allLayoutName.push_back(sTmpLayoutName); } pDict->close(); delete pIter; return true; }
设置当前布局名的代码调用,该调用最好在命令中进行
if(Mx::mcdbHostApplicationServices()->layoutManager()->setCurrentLayout(sLayoutName) == Mcad::eOk) { return TRUE; } else { return FALSE; }