arx 布局中添加视口:布局名称、视口中心、视口宽、视口高
// 布局中添加视口:布局名称、视口中心、视口宽、视口高void Vport::InSpace(const CString &space,
const AcGePoint3d &pc,
double width,
double height)
{ // 布局管理器中切换当前视口为布局1
Acad::ErrorStatus es = acdbHostApplicationServices()->
layoutManager()->setCurrentLayout(space);
// 如果失败,直接返回主程序
if (es != Acad::eOk)
return;
// 块表->布局空间块表记录->关闭块表
AcDbBlockTable *pBlkTbl = NULL;
acdbHostApplicationServices()->workingDatabase()->
getBlockTable(pBlkTbl, AcDb::kForRead);
AcDbBlockTableRecord *pBlkTblRcd = NULL;
pBlkTbl->getAt(ACDB_PAPER_SPACE, pBlkTblRcd, AcDb::kForWrite);
pBlkTbl->close();
// 新建视口:设置中心点,宽,高
AcDbViewport *pViewport = new AcDbViewport();
pViewport->setCenterPoint(pc);
pViewport->setHeight(height);
pViewport->setWidth(width);
// 添加进视口记录中:返回记录idviewportId
AcDbObjectId viewportId;
pBlkTblRcd->appendAcDbEntity(viewportId, pViewport);
pViewport->close();
pBlkTblRcd->close();
// 创建布局视口表对象,区别于AcDbViewportTable(模型视口表对象)
AcDbViewport *pVP = NULL;
if (acdbOpenObject(pVP, viewportId, AcDb::kForWrite) == Acad::eOk)
{ // 添加后要显示视口必须打开
pVP->setOn();
// 把新建的视口设成当前活动视口
acedSetCurrentVPort(pVP);
pVP->close();
}
}
页:
[1]