static void RivilisInsertVertex () {
ads_point p; ads_name entPoly;
resbuf view; acedGetVar (_T("VIEWSIZE"), &view);
double gsize = view.resval.rreal * 0.03;
AcDbObjectId vertexAfterId;
AcDbObjectId newVertexId;
AcGePoint3d pointAfter;
if (acedEntSel(_T("\nВыберите 3D-полилинию: "), entPoly, p) == RTNORM) {
AcDbObjectId pObjId;
if (acdbGetObjectId(pObjId,entPoly) == Acad::eOk) {
AcDbObjectPointer<AcDb3dPolyline> poly3d(pObjId,AcDb::kForWrite);
if (poly3d.openStatus() != Acad::eOk) return;
AcDbObjectIterator *pVertIter= poly3d->vertexIterator();
AcDbObjectId vertexObjId;
for (;!pVertIter->done();pVertIter->step()) {
vertexObjId = pVertIter->objectId();
AcDbObjectPointer<AcDb3dPolylineVertex> pVertex(vertexObjId,AcDb::kForRead);
AcGePoint3d vPts = pVertex->position();
acdbWcs2Ucs(asDblArray(vPts),asDblArray(vPts),0);
acedGrDraw(asDblArray(vPts - AcGeVector3d(gsize,gsize,0)),
asDblArray(vPts + AcGeVector3d(gsize,gsize,0)),1,1);
acedGrDraw(asDblArray(vPts - AcGeVector3d(gsize,-gsize,0)),
asDblArray(vPts + AcGeVector3d(gsize,-gsize,0)),1,1);
acedInitGet(RSG_OTHER,_T("Да Нет Yes No _ Yes No Yes No"));
ACHAR ans[512];
int rc = 0;
if ((rc = acedGetKword(_T("\nВставить вершину после этой вершины? [Да/Нет] <Нет>: "),ans)) == RTNORM) {
if (!_tcsicmp(ans,_T("")) || !_tcsicmp(ans,_T("YES"))) {
vertexAfterId = vertexObjId;
pointAfter = vPts;
acedRedraw(NULL,1);
break;
}
} else if (rc == RTCAN) {
acedRedraw(NULL,1);
break;
}
acedRedraw(NULL,1);
}
delete pVertIter;
if (!vertexAfterId.isNull()) {
acedInitGet(1,NULL);
if (acedGetPoint(asDblArray(pointAfter),_T("\nУкажите точку: "),asDblArray(pointAfter)) == RTNORM) {
acdbUcs2Wcs(asDblArray(pointAfter),asDblArray(pointAfter),0);
AcDb3dPolylineVertex *vertex = new AcDb3dPolylineVertex(pointAfter);
poly3d->insertVertexAt(newVertexId,vertexAfterId,vertex);
vertex->close();
}
}
}
if (!newVertexId.isNull()) {
AcDbObjectPointer<AcDb3dPolylineVertex> pVertex(newVertexId,AcDb::kForWrite);
pVertex->setPosition(pointAfter);
}
}
}