|
bool AddPaperLayout( AcDbObjectId& idLay,LPCTSTR lpszLayName ,LPCTSTR lpszMediaName/* = _T("A3")*/)
{
AfxIsValidString(lpszLayName);
AfxIsValidString(lpszMediaName);
const ACHAR* LayoutName = lpszLayName;
Acad::ErrorStatus es;
AcApLayoutManager* pLayoutMng = (AcApLayoutManager*)acdbHostApplicationServices()->layoutManager();
AcDbLayout* pNewLayout = pLayoutMng->findLayoutNamed(LayoutName);
if(pNewLayout)
{
return true;
}
AcDbObjectId blockTableRecId;
pLayoutMng->setCreateViewports(Adesk::kTrue);
es = pLayoutMng->createLayout(LayoutName, idLay, blockTableRecId);
if (eOk != es)
{
return false;
}
pNewLayout = pLayoutMng->findLayoutNamed(LayoutName, true);
AcDbPlotSettingsValidator *pPltValid = NULL;
pPltValid = acdbHostApplicationServices()->plotSettingsValidator();
pPltValid->refreshLists(pNewLayout);
const ACHAR* mediaName = lpszMediaName;
pPltValid->setCanonicalMediaName(pNewLayout,mediaName);//设置图纸尺寸
pPltValid->setPlotRotation(pNewLayout,AcDbPlotSettings::k90degrees);
pNewLayout->close();
es = pLayoutMng->setCurrentLayoutId(idLay);
pLayoutMng->updateCurrentPaper(Adesk::kTrue);
pLayoutMng->updateLayoutTabs();
return true;
} |
|