天天看点

Arx 新建布局(Creating new Paperspace)

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;
}
           

更多操作可查看http://forums.autodesk.com/t5/Autodesk-ObjectARX/Creating-new-Paperspace-with-Rotated-Viewport/td-p/3285119

Arx