neu_sjy 发表于 2008-4-9 09:27:00

[原创]高手帮帮忙 如何在图纸空间创建新视口并实现缩放!!!

<p>void CDrawTu::CreateSK()<br/>{<br/>&nbsp;// 指定当前布局<br/>&nbsp;Acad::ErrorStatus es =<br/>&nbsp;&nbsp;acdbHostApplicationServices()-&gt;layoutManager()<br/>&nbsp;&nbsp;-&gt;setCurrentLayout(_T("布局1"));<br/>&nbsp;if (es != Acad::eOk)<br/>&nbsp;{<br/>&nbsp;&nbsp;return;<br/>&nbsp;}<br/>&nbsp;// 获得块表<br/>&nbsp;AcDbBlockTable *pBlkTbl;<br/>&nbsp;acdbHostApplicationServices()-&gt;workingDatabase()<br/>&nbsp;&nbsp;-&gt;getBlockTable(pBlkTbl, AcDb::kForRead);<br/>&nbsp;// 获得图纸空间的块表记录<br/>&nbsp;AcDbBlockTableRecord *pBlkTblRcd;<br/>&nbsp;pBlkTbl-&gt;getAt(ACDB_PAPER_SPACE, pBlkTblRcd,<br/>&nbsp;&nbsp;AcDb::kForWrite);<br/>&nbsp;pBlkTbl-&gt;close();<br/>&nbsp;// 创建新的布局对象<br/>&nbsp;AcDbViewport *pViewport = new AcDbViewport();<br/>&nbsp;pViewport-&gt;setCenterPoint(AcGePoint3d(50, 50, 0));<br/>&nbsp;pViewport-&gt;setHeight(80);<br/>&nbsp;pViewport-&gt;setWidth(120);<br/>&nbsp;// 将新的布局对象添加到图纸空间块表记录中<br/>&nbsp;AcDbObjectId viewportId;<br/>&nbsp;pBlkTblRcd-&gt;appendAcDbEntity(viewportId, pViewport);<br/>&nbsp;pViewport-&gt;close();<br/>&nbsp;pBlkTblRcd-&gt;close();<br/>&nbsp;// 将新建的视口作为当前视口<br/>&nbsp;AcDbViewport *pVP;<br/>&nbsp;acdbOpenObject(pVP, viewportId, AcDb::kForWrite);<br/>&nbsp;pViewport-&gt;setOn();<br/>&nbsp;int vpNum = pViewport-&gt;number();<br/>&nbsp;pVP-&gt;close();<br/>&nbsp;acedCommand(RTSTR, _T("_PSPACE"), 0);<br/>&nbsp;es = acedSetCurrentVPort(pVP);<br/>&nbsp;acedCommand(RTSTR, _T("_ZOOM"), RTSTR, _T("_Extents"), 0);<br/>}</p><p>&nbsp;以上代码实现了创建新视口 但是没能实现缩放 而且原有视口如何删除 请各位高手指点一下</p>
页: [1]
查看完整版本: [原创]高手帮帮忙 如何在图纸空间创建新视口并实现缩放!!!