|
发表于 2024-7-28 09:28:43
|
显示全部楼层
图纸空间创建一个新的视口:- void ZffCHAP4CreateVPortInSpace()
- {
- // 指定当前布局
- Acad::ErrorStatus es = acdbHostApplicationServices()->layoutManager()->setCurrentLayout("布局1");
- 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(AcGePoint3d(100, 50, 0));
- pViewport->setHeight(80);
- pViewport->setWidth(120);
-
- // 将新的布局对象添加到图纸空间块表记录中
- AcDbObjectId viewportId;
- pBlkTblRcd->appendAcDbEntity(viewportId, pViewport);
- pViewport->close();
- pBlkTblRcd->close();
-
- // 将新建的视口作为当前视口
- AcDbViewport *pVP = NULL;
- acdbOpenObject(pVP, viewportId, AcDb::kForWrite);
- pViewport->setOn();//创建浮动视口之后,要想启用该视口,必须使用 setOn 函数
- acedSetCurrentVPort(pVP);
- pVP->close();
- }
复制代码 |
|