码迷,mamicode.com
首页 > 其他好文 > 详细

设置视口中心点setViewCenter

时间:2019-04-27 00:34:03      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:str   ret   struct   模型   ||   ssg   nstat   jid   style   

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 = 1;
        dcs.restype = RTSHORT;
        dcs.resval.rint = 2;        
        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=0;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);

 

设置视口中心点setViewCenter

标签:str   ret   struct   模型   ||   ssg   nstat   jid   style   

原文地址:https://www.cnblogs.com/edata/p/10777244.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!