我想在模型空间中选一多边形,然后在布局空间把这个多边形区域用视口剪切出来,可用旋转和缩放.现在我在旋转时发现视口边界里面的图形与模型空间的多边形不完全重合,缩放是没有问题的. AcDbViewport *pViewport = new AcDbViewport(); pViewport->setCenterPoint(AcGePoint3d(printableXmin/2+printableXmax/2, printableYmin/2+printableYmax/2,0)); double width,height;width=0;height=0; width=GetViewportWidth(trimobjectid); height=GetViewportHeigth(trimobjectid); pViewport->setHeight(height); pViewport->setWidth(width); AcGePoint3d rotatemodelcenterpt; rotatemodelcenterpt=GetModelSpaceObjectCenter(entId); rotatemodelcenterpt=rotatemodelcenterpt.rotateBy(twistangle,AcGeVector3d(0,0,1)); pViewport->setViewCenter(AcGePoint2d(rotatemodelcenterpt.x,rotatemodelcenterpt.y)); pViewport->setLensLength(50.0); pViewport->setNonRectClipEntityId(trimobjectid); pViewport->setNonRectClipOn(); pViewport->setViewHeight(height*scale); pViewport->setViewDirection(AcGeVector3d(0,0,1)); SetViewPortScale(pViewport,scale); pViewport->setTwistAngle(twistangle); // 将新的布局对象添加到图纸空间块表记录中 AcDbObjectId viewportId; pBlkTblRcd->appendAcDbEntity(viewportId, pViewport); //pViewport->downgradeOpen(); pViewport->setOn(); pViewport->upgradeOpen(); pViewport->close(); pBlkTblRcd->close(); |