|
Removing a vertex from AcDb2dPolyline using ObjectARX?
使用 ObjectARX 从 AcDb2dPolyline 中删除顶点?
有没有办法从 AcDb2dPolyline/AcDb3dPolyline 中删除顶点(类似于 AcDbPolyline::removeVertexAt() ) ?
2d 和 3d 折线没有类似的移除功能,主要是因为存储机制不同。AcDbPolyline 可以更有效地将其顶点存储为单个实体中的数组,而对于 2d 和 3d 折线,顶点存储为单独的实体。因此,您将必须访问单个顶点实体并显式删除它。删除不会通过 2d/3d 折线图元本身发生。请尝试以下代码段。
查看以下代码片段:这将删除第一个顶点。
[code]void EraseVertex()
{
ads_name name; ads_point pt;
// pick a polyline 2d
int res = acedEntSel(_T("\nPick a 2dpolyline"), name, pt);
// if ok
if (res == RTNORM)
{
AcDbObjectId plineObjId;
// convert the ename to an AcDbObjectId
Acad::ErrorStatus es = acdbGetObjectId(plineObjId, name);
AcDbObjectPointer<AcDb2dPolyline> pPlineEnt(plineObjId, AcDb::kForRead);
// if we have the right entity type
if (pPlineEnt.openStatus() == Acad::eOk)
{
AcDbObjectIterator* pVertIter = pPlineEnt->vertexIterator();
// select the 1st vertex in AcDb2dPolyline; regen to see change
AcDbObjectPointer<AcDb2dVertex> pVertex(pVertIter->objectId(), AcDb::kForWrite);
// check to see if it is not already erased
if (es != Acad::eWasErased)
{
Adesk::Boolean bErased = pVertex->isErased();
if (!bErased)
es = pVertex->erase();
}
}
delete pVertIter;
}
}[/code] |
|