使用ObjectARX事务功能做小动画处理

发布时间:2024年01月06日

使用ObjectARX事务功能做小动画处理,可以用于几何算法调试等

void CmdFun::Test()
{
    if (true)
    {
        ads_point pt;
        ads_name en;
        if (RTNORM != acedEntSel(_T("\n选中对象 : "), en, pt))
            return;
        AcDbObjectId id;
        if (Acad::eOk != acdbGetObjectId(id, en))
            return;
        AcTransaction* pTransaction = actrTransactionManager->startTransaction();
        do
        {
            AcDbEntity* pEnt = NULL;
            actrTransactionManager->getObject((AcDbObject*&)pEnt, id, AcDb::kForWrite);
            AcDbPolyline* poly = NULL;

            AcGePoint2d ptStart;
            if (pEnt->isKindOf(AcDbPolyline::desc()))
            {
                poly = AcDbPolyline::cast(pEnt);
                poly->getPointAt(0, ptStart);
                unsigned int vertexCount = poly->numVerts();
                for (unsigned int i = 0; i < vertexCount; i++)
                {
                    poly->removeVertexAt(i);
                }
            }
            else
            {
                break;
            }
            poly->addVertexAt(0, ptStart);
            poly->addVertexAt(1, ptStart);
            poly->setWidthsAt(0, 100.0, 100.0);
            for (size_t i = 0; i < 1000; i++)
            {
                AcGePoint2d ptEnd = ptStart + AcGeVector2d::kXAxis * i * 10.0;
                poly->setPointAt(1, ptEnd);
                poly->setColorIndex(i % 256);
                Sleep(1);
                poly->draw();
                acedUpdateDisplay();
            }
        } while (0);
        actrTransactionManager->abortTransaction();
        return;
    }
}

在这里插入图片描述

文章来源:https://blog.csdn.net/zeqi1991/article/details/135428765
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。