ads_point pt;
ads_name ent,ss;
//切换到模型空间
acedMspace();
if (RTNORM != acedGetPoint(NULL,_T("\n选择新的视口中心点:"),pt))
{
return;
}
acutPrintf(_T("\n拾取视口中心点(%0.4lf,%0.4lf)"),pt[X],pt[Y]);
// 转换坐标系的标记
struct resbuf ucs, dcs;
ucs.restype = RTSHORT;
ucs.resval.rint = ;
dcs.restype = RTSHORT;
dcs.resval.rint = ;
acedTrans(pt,&ucs,&dcs,NULL,pt);
AcGePoint2d ptCenter=asPnt2d(pt);
//切换到图纸空间
acedPspace();
if (RTNORM != acedSSGet(NULL,NULL,NULL,NULL,ss))
{
return;
}
Adesk::Int32 nLength;
acedSSLength(ss,&nLength);
for (Adesk::Int32 i=;i<nLength;i++)
{
AcDbObjectId objId=AcDbObjectId::kNull;
acedSSName(ss,i,ent);
acdbGetObjectId(objId,ent);
AcDbObjectPointer<AcDbViewport> pVp(objId,AcDb::kForWrite);
if (Acad::eOk != pVp.openStatus() || pVp == NULL)
{
continue;
}
//pVp->setViewCenter()
AcGePoint2d ptOld= pVp->viewCenter();
acutPrintf(_T("\n原有视口中心点(%0.4lf,%0.4lf)"),ptOld.x,ptOld.y);
acutPrintf(_T("\n设置视口中心点(%0.4lf,%0.4lf)"),ptCenter.x,ptCenter.y);
pVp->setViewCenter(ptCenter);
ptOld= pVp->viewCenter();
acutPrintf(_T("\n结果视口中心点(%0.4lf,%0.4lf)"),ptOld.x,ptOld.y);
}
acedSSFree(ss);
05-11 18:12