ObjectARX中三维多段线转二维多段线的方法
Posted laoxugiser
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ObjectARX中三维多段线转二维多段线的方法相关的知识,希望对你有一定的参考价值。
Acad::ErrorStatus AcDb3dPolylineToAcDb2dPolyline(AcDbObjectId objId, int flag /* =0 */) { Acad::ErrorStatus es; AcDbEntity *pEnt = NULL; double elev = 0.0; es = acdbOpenObject(pEnt, objId, AcDb::kForWrite); int i = 0; if (pEnt->isKindOf(AcDb3dPolyline::desc())) { AcDb2dPolyline *pNewline = new AcDb2dPolyline(); AcDb3dPolyline *pPline = AcDb3dPolyline::cast(pEnt); AcDbObjectIterator *pItr = pPline->vertexIterator(); for (pItr->start(); !pItr->done(); pItr->step()) { AcDb3dPolylineVertex *pVertex = NULL; AcDbObjectId vId = pItr->objectId(); acdbOpenObject(pVertex, vId, AcDb::kForRead); AcDb::Vertex3dType verType = pVertex->vertexType(); if (verType != AcDb::k3dControlVertex) { i++; AcDb2dVertex *p2dVertex = new AcDb2dVertex(pVertex->position()); p2dVertex->setXData(pVertex->xData()); pNewline->appendVertex(p2dVertex); p2dVertex->close(); } if (flag == 1) { elev += pVertex->position().z; } pVertex->close(); } delete pItr; pItr = 0; double eleva = elev / i; pNewline->setElevation(eleva); pNewline->setPropertiesFrom(pPline); if (pPline->isClosed()) { pNewline->makeClosed(); } pNewline->setXData(pPline->xData()); m_DbUtil.PostToModelSpace(pNewline); pPline->erase(); } pEnt->close(); return es; }
以上是关于ObjectARX中三维多段线转二维多段线的方法的主要内容,如果未能解决你的问题,请参考以下文章