<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Remove a vertex in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/remove-a-vertex/m-p/2196913#M75354</link>
    <description>[code]&lt;BR /&gt;
static void DelVertex(void)&lt;BR /&gt;
{&lt;BR /&gt;
  ads_name ssName;&lt;BR /&gt;
  ads_point ptres;&lt;BR /&gt;
  int nRet = acedEntSel(_T("\nSelect 3D-polyline: "), ssName, ptres);&lt;BR /&gt;
  if(nRet!=RTNORM) {&lt;BR /&gt;
    acutPrintf(_T("\nLine not selected"));&lt;BR /&gt;
    return;&lt;BR /&gt;
  }&lt;BR /&gt;
&lt;BR /&gt;
  AcDbObjectId lineId;&lt;BR /&gt;
  AcDbObjectIterator *pVtxIt = NULL;&lt;BR /&gt;
  AcDbObjectIdArray aVtxIds;&lt;BR /&gt;
  int iVtx = 1;&lt;BR /&gt;
  if (acdbGetObjectId(lineId, ssName) == Acad::eOk)  {&lt;BR /&gt;
    AcDbObjectPointer&lt;ACDB3DPOLYLINE&gt; pPoly(lineId, AcDb::kForWrite);&lt;BR /&gt;
    if (pPoly.openStatus() != Acad::eOk) return;&lt;BR /&gt;
    pVtxIt = pPoly-&amp;gt;vertexIterator();&lt;BR /&gt;
    AcDbObjectId firstId = pVtxIt-&amp;gt;objectId();&lt;BR /&gt;
    if(pVtxIt-&amp;gt;objectId().isErased()) {&lt;BR /&gt;
      pVtxIt-&amp;gt;step();&lt;BR /&gt;
      firstId = pVtxIt-&amp;gt;objectId();&lt;BR /&gt;
    }&lt;BR /&gt;
    for (pVtxIt-&amp;gt;setPosition(firstId); !pVtxIt-&amp;gt;done(); pVtxIt-&amp;gt;step()){&lt;BR /&gt;
      if(pVtxIt-&amp;gt;objectId().isErased()) continue;&lt;BR /&gt;
      aVtxIds.append(pVtxIt-&amp;gt;objectId());&lt;BR /&gt;
    }&lt;BR /&gt;
    delete pVtxIt;&lt;BR /&gt;
  } else return;&lt;BR /&gt;
  ACHAR prompt[128]=_T("");&lt;BR /&gt;
  sprintf(prompt,_T("\nSelect number of vertex (1 - %d): "),aVtxIds.length());&lt;BR /&gt;
  Acad:ErrorStatus es;&lt;BR /&gt;
  while (acedGetInt(prompt,&amp;amp;iVtx) == RTNORM &amp;amp;&amp;amp; (iVtx &amp;lt; 1 || iVtx &amp;gt; aVtxIds.length())) {&lt;BR /&gt;
    acutPrintf(_T("\nError vertex number!"));&lt;BR /&gt;
  }&lt;BR /&gt;
  if (iVtx &amp;gt;= 1 &amp;amp;&amp;amp; iVtx &amp;lt;= aVtxIds.length()) {&lt;BR /&gt;
    {&lt;BR /&gt;
       AcDbObjectPointer&lt;ACDB3DPOLYLINEVERTEX&gt; pVt(aVtxIds[iVtx-1], AcDb::kForWrite);&lt;BR /&gt;
       if (pVt.openStatus() == Acad::eOk) {&lt;BR /&gt;
        es = pVt-&amp;gt;erase(true);&lt;BR /&gt;
        if (es != Acad::eOk) {&lt;BR /&gt;
         acutPrintf(_T("\nError deleting vertex: %s"), acadErrorStatusText(es));&lt;BR /&gt;
        }&lt;BR /&gt;
       }&lt;BR /&gt;
    }&lt;BR /&gt;
    {&lt;BR /&gt;
      AcDbObjectPointer&lt;ACDB3DPOLYLINE&gt; pPoly(lineId, AcDb::kForWrite);&lt;BR /&gt;
      if (pPoly.openStatus() == Acad::eOk) {&lt;BR /&gt;
        pPoly-&amp;gt;recordGraphicsModified(true);&lt;BR /&gt;
      }&lt;BR /&gt;
    }&lt;BR /&gt;
  }&lt;BR /&gt;
}&lt;BR /&gt;
[/code]&lt;/ACDB3DPOLYLINE&gt;&lt;/ACDB3DPOLYLINEVERTEX&gt;&lt;/ACDB3DPOLYLINE&gt;</description>
    <pubDate>Wed, 05 Mar 2008 12:38:56 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2008-03-05T12:38:56Z</dc:date>
    <item>
      <title>Remove a vertex</title>
      <link>https://forums.autodesk.com/t5/net-forum/remove-a-vertex/m-p/2196912#M75353</link>
      <description>So as my topic says, how do I remove a vertex from a polyline3d?&lt;BR /&gt;
&lt;BR /&gt;
Thank for replying,&lt;BR /&gt;
Bert</description>
      <pubDate>Wed, 05 Mar 2008 12:11:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/remove-a-vertex/m-p/2196912#M75353</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-03-05T12:11:02Z</dc:date>
    </item>
    <item>
      <title>Re: Remove a vertex</title>
      <link>https://forums.autodesk.com/t5/net-forum/remove-a-vertex/m-p/2196913#M75354</link>
      <description>[code]&lt;BR /&gt;
static void DelVertex(void)&lt;BR /&gt;
{&lt;BR /&gt;
  ads_name ssName;&lt;BR /&gt;
  ads_point ptres;&lt;BR /&gt;
  int nRet = acedEntSel(_T("\nSelect 3D-polyline: "), ssName, ptres);&lt;BR /&gt;
  if(nRet!=RTNORM) {&lt;BR /&gt;
    acutPrintf(_T("\nLine not selected"));&lt;BR /&gt;
    return;&lt;BR /&gt;
  }&lt;BR /&gt;
&lt;BR /&gt;
  AcDbObjectId lineId;&lt;BR /&gt;
  AcDbObjectIterator *pVtxIt = NULL;&lt;BR /&gt;
  AcDbObjectIdArray aVtxIds;&lt;BR /&gt;
  int iVtx = 1;&lt;BR /&gt;
  if (acdbGetObjectId(lineId, ssName) == Acad::eOk)  {&lt;BR /&gt;
    AcDbObjectPointer&lt;ACDB3DPOLYLINE&gt; pPoly(lineId, AcDb::kForWrite);&lt;BR /&gt;
    if (pPoly.openStatus() != Acad::eOk) return;&lt;BR /&gt;
    pVtxIt = pPoly-&amp;gt;vertexIterator();&lt;BR /&gt;
    AcDbObjectId firstId = pVtxIt-&amp;gt;objectId();&lt;BR /&gt;
    if(pVtxIt-&amp;gt;objectId().isErased()) {&lt;BR /&gt;
      pVtxIt-&amp;gt;step();&lt;BR /&gt;
      firstId = pVtxIt-&amp;gt;objectId();&lt;BR /&gt;
    }&lt;BR /&gt;
    for (pVtxIt-&amp;gt;setPosition(firstId); !pVtxIt-&amp;gt;done(); pVtxIt-&amp;gt;step()){&lt;BR /&gt;
      if(pVtxIt-&amp;gt;objectId().isErased()) continue;&lt;BR /&gt;
      aVtxIds.append(pVtxIt-&amp;gt;objectId());&lt;BR /&gt;
    }&lt;BR /&gt;
    delete pVtxIt;&lt;BR /&gt;
  } else return;&lt;BR /&gt;
  ACHAR prompt[128]=_T("");&lt;BR /&gt;
  sprintf(prompt,_T("\nSelect number of vertex (1 - %d): "),aVtxIds.length());&lt;BR /&gt;
  Acad:ErrorStatus es;&lt;BR /&gt;
  while (acedGetInt(prompt,&amp;amp;iVtx) == RTNORM &amp;amp;&amp;amp; (iVtx &amp;lt; 1 || iVtx &amp;gt; aVtxIds.length())) {&lt;BR /&gt;
    acutPrintf(_T("\nError vertex number!"));&lt;BR /&gt;
  }&lt;BR /&gt;
  if (iVtx &amp;gt;= 1 &amp;amp;&amp;amp; iVtx &amp;lt;= aVtxIds.length()) {&lt;BR /&gt;
    {&lt;BR /&gt;
       AcDbObjectPointer&lt;ACDB3DPOLYLINEVERTEX&gt; pVt(aVtxIds[iVtx-1], AcDb::kForWrite);&lt;BR /&gt;
       if (pVt.openStatus() == Acad::eOk) {&lt;BR /&gt;
        es = pVt-&amp;gt;erase(true);&lt;BR /&gt;
        if (es != Acad::eOk) {&lt;BR /&gt;
         acutPrintf(_T("\nError deleting vertex: %s"), acadErrorStatusText(es));&lt;BR /&gt;
        }&lt;BR /&gt;
       }&lt;BR /&gt;
    }&lt;BR /&gt;
    {&lt;BR /&gt;
      AcDbObjectPointer&lt;ACDB3DPOLYLINE&gt; pPoly(lineId, AcDb::kForWrite);&lt;BR /&gt;
      if (pPoly.openStatus() == Acad::eOk) {&lt;BR /&gt;
        pPoly-&amp;gt;recordGraphicsModified(true);&lt;BR /&gt;
      }&lt;BR /&gt;
    }&lt;BR /&gt;
  }&lt;BR /&gt;
}&lt;BR /&gt;
[/code]&lt;/ACDB3DPOLYLINE&gt;&lt;/ACDB3DPOLYLINEVERTEX&gt;&lt;/ACDB3DPOLYLINE&gt;</description>
      <pubDate>Wed, 05 Mar 2008 12:38:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/remove-a-vertex/m-p/2196913#M75354</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-03-05T12:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: Remove a vertex</title>
      <link>https://forums.autodesk.com/t5/net-forum/remove-a-vertex/m-p/2196914#M75355</link>
      <description>Thanks for your reply.  It's very nice.  But I forgot to say that I'm not used to C# and C++ code.  I tried to understand but it seems that I'm not there for now.  Look at my code.  It works but it do nothing.&lt;BR /&gt;
&lt;BR /&gt;
PS.: Forget about the transaction, it's initialized and finished outside the function.&lt;BR /&gt;
&lt;BR /&gt;
Imports Autodesk.AutoCAD&lt;BR /&gt;
Imports Autodesk.AutoCAD.ApplicationServices&lt;BR /&gt;
Imports Autodesk.AutoCAD.DatabaseServices&lt;BR /&gt;
Imports Autodesk.AutoCAD.EditorInput&lt;BR /&gt;
Imports Autodesk.AutoCAD.Runtime&lt;BR /&gt;
Imports Autodesk.AutoCAD.Geometry&lt;BR /&gt;
&lt;BR /&gt;
Module MyFunctions&lt;BR /&gt;
Function CorrectCoordinates(ByVal Poly3d As Polyline3d) As Point3dCollection&lt;BR /&gt;
    Dim P3dCol As New Point3dCollection&lt;BR /&gt;
&lt;BR /&gt;
    Try&lt;BR /&gt;
        For Each objID As ObjectId In Poly3d&lt;BR /&gt;
&lt;BR /&gt;
            Dim vtx As PolylineVertex3d = BertTrans.GetObject(objID, OpenMode.ForRead)&lt;BR /&gt;
            If P3dCol.Count &amp;gt; 0 Then&lt;BR /&gt;
&lt;BR /&gt;
                If vtx.Position.IsEqualTo(P3dCol(P3dCol.Count - 1), New Tolerance(0, 0.001)) Then&lt;BR /&gt;
                    vtx.UpgradeOpen()&lt;BR /&gt;
&lt;BR /&gt;
                    'I try to erase the vertex from here!&lt;BR /&gt;
                    vtx.Erase()&lt;BR /&gt;
                    vtx.Dispose()&lt;BR /&gt;
&lt;BR /&gt;
                Else&lt;BR /&gt;
                    P3dCol.Add(vtx.Position)&lt;BR /&gt;
                End If&lt;BR /&gt;
&lt;BR /&gt;
            Else&lt;BR /&gt;
                P3dCol.Add(vtx.Position)&lt;BR /&gt;
            End If&lt;BR /&gt;
&lt;BR /&gt;
        Next&lt;BR /&gt;
        Return P3dCol&lt;BR /&gt;
    Catch ex As Exception&lt;BR /&gt;
        MsgBox(ex.Message)&lt;BR /&gt;
        Return Nothing&lt;BR /&gt;
    End Try&lt;BR /&gt;
&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
End Module&lt;BR /&gt;
&lt;BR /&gt;
Thank,&lt;BR /&gt;
Bert</description>
      <pubDate>Wed, 05 Mar 2008 23:59:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/remove-a-vertex/m-p/2196914#M75355</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-03-05T23:59:27Z</dc:date>
    </item>
  </channel>
</rss>

