以下示例演示如何使用顶点迭代器循环访问折线中的顶点。然后,它会打印每个顶点的坐标。 // 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; } |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-8 19:41
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.