ObjectARX延时动画效果简单示意

 

 测试代码如下

        ads_point pt;
        ads_name ent;
        if (RTNORM != acedEntSel(_T("\n选择对象: "),ent,pt))
        {
            return;
        }
        AcDbObjectId objId;
        acdbGetObjectId(objId,ent);
        if (objId.isNull())
        {
            return;
        }
        AcDbEntityPointer pEnt(objId,AcDb::kForRead);
        Acad::ErrorStatus es = pEnt.openStatus();
        if (Acad::eOk != es)
        {
            return;
        }
        AcDbBlockTableRecordPointer pBlkRcd(curDoc()->database()->currentSpaceId(),AcDb::kForWrite);
        es = pBlkRcd.openStatus();
        if (Acad::eOk != es)
        {
            return;
        }
        for (int i=1;i<50;i++)
        {            
            AcDbEntity *pClone =AcDbEntity::cast(pEnt->clone());
            if (pClone == NULL)
            {
                continue;
            }
            AcDbEntityPointer pCopy;
            es = pCopy.acquire(pClone);
            if (Acad::eOk != es)
            {
                delete pClone;
                continue;
            }
            AcGeMatrix3d mat;
            mat.setToTranslation(AcGeVector3d(i*100,0,0));
            pCopy->transformBy(mat);
            pCopy->setColorIndex(i);
            pBlkRcd->appendAcDbEntity(pCopy);
            //绘出图形
            pCopy->draw();
            //更新显示
            acedUpdateDisplay();
            //延时100ms
            Sleep(100);
            //_sleep(100);            
        }

 

posted @ 2020-12-18 13:53  edata  阅读(211)  评论(0编辑  收藏  举报