[code]
static void DelVertex(void)
{
ads_name ssName;
ads_point ptres;
int nRet = acedEntSel(_T("\nSelect 3D-polyline: "), ssName, ptres);
if(nRet!=RTNORM) {
acutPrintf(_T("\nLine not selected"));
return;
}
AcDbObjectId lineId;
AcDbObjectIterator *pVtxIt = NULL;
AcDbObjectIdArray aVtxIds;
int iVtx = 1;
if (acdbGetObjectId(lineId, ssName) == Acad::eOk) {
AcDbObjectPointer
pPoly(lineId, AcDb::kForWrite);
if (pPoly.openStatus() != Acad::eOk) return;
pVtxIt = pPoly->vertexIterator();
AcDbObjectId firstId = pVtxIt->objectId();
if(pVtxIt->objectId().isErased()) {
pVtxIt->step();
firstId = pVtxIt->objectId();
}
for (pVtxIt->setPosition(firstId); !pVtxIt->done(); pVtxIt->step()){
if(pVtxIt->objectId().isErased()) continue;
aVtxIds.append(pVtxIt->objectId());
}
delete pVtxIt;
} else return;
ACHAR prompt[128]=_T("");
sprintf(prompt,_T("\nSelect number of vertex (1 - %d): "),aVtxIds.length());
Acad:ErrorStatus es;
while (acedGetInt(prompt,&iVtx) == RTNORM && (iVtx < 1 || iVtx > aVtxIds.length())) {
acutPrintf(_T("\nError vertex number!"));
}
if (iVtx >= 1 && iVtx <= aVtxIds.length()) {
{
AcDbObjectPointer pVt(aVtxIds[iVtx-1], AcDb::kForWrite);
if (pVt.openStatus() == Acad::eOk) {
es = pVt->erase(true);
if (es != Acad::eOk) {
acutPrintf(_T("\nError deleting vertex: %s"), acadErrorStatusText(es));
}
}
}
{
AcDbObjectPointer pPoly(lineId, AcDb::kForWrite);
if (pPoly.openStatus() == Acad::eOk) {
pPoly->recordGraphicsModified(true);
}
}
}
}
[/code]