CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ObjectARX 开发指南

在折线中遍历折点

2023-1-1 04:07| 发布者: admin| 查看: 274| 评论: 0|来自: AutoCAD

以下示例演示如何使用顶点迭代器循环访问折线中的顶点。然后,它会打印每个顶点的坐标。

// Accepts the object ID of an AcDb2dPolyline, opens it, and gets
// a vertex iterator. It then iterates through the vertices,
// printing out the vertex location.
// 
void
iterate(AcDbObjectId plineId)
{
    AcDb2dPolyline *pPline;
    acdbOpenObject(pPline, plineId, AcDb::kForRead);
    AcDbObjectIterator *pVertIter= pPline->vertexIterator();
    pPline->close();  // Finished with the pline header.
    AcDb2dVertex *pVertex;
    AcGePoint3d location;
    AcDbObjectId vertexObjId;
    for (int vertexNumber = 0; !pVertIter->done();
        vertexNumber++, pVertIter->step())
    {
        vertexObjId = pVertIter->objectId();
        acdbOpenObject(pVertex, vertexObjId,
            AcDb::kForRead);
        location = pVertex->position();
        pVertex->close();
        acutPrintf("\nVertex #%d's location is"
            " : %0.3f, %0.3f, %0.3f", vertexNumber,
            location[X], location[Y], location[Z]);
    }
    delete pVertIter;
}

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-19 15:28

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部