ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AcDbPolyline show vertexes

1 REPLY 1
SOLVED
Reply
Message 1 of 2
DonatasAzaravicius
303 Views, 1 Reply

AcDbPolyline show vertexes

I am writing function to remove vertexes from AcDbPolyline. My function works, but I can't see vertexes of AcDbPolyline if command is active.

I want it to look like this than I select vertexes

DonatasAzaravicius_0-1648217996068.png

But it looks like this

DonatasAzaravicius_1-1648218097815.png

How can I make AcDbPolyline look like first image in process of selecting vertexes?

My current code is

void removeVertexFromPoly()
{
    int ec = RTERROR;
    ads_point adsPoint;
    ads_name ent;
    AcDbObjectId id;
    Acad::ErrorStatus es = Acad::eOk;
    AcDbObjectPointer<AcDbPolyline> pPoly;
    while(ec != RTNORM)
    {
        ec = acedEntSel( _T( "\nSelect polyline:" ), ent, adsPoint );
        if(ec == RTCAN) return;

        es = acdbGetObjectId( id, ent );
        if(es != Acad::eOk)
        {
            acutPrintf( _T( "\nacdbGetObjectId failed. Error: %s" ), acadErrorStatusText( es ) );
            return;
        }

        pPoly.open( id, AcDb::kForRead );
        if((es = pPoly.openStatus()) == Acad::eNotThatKindOfClass)
        {
            acutPrintf( _T( "\nNot a polyline! " ) );
            ec = RTERROR;
            continue;
        }
        else if((es = pPoly.openStatus()) != Acad::eOk)
        {
            acutPrintf( _T( "\nCould not open polyline. Error: %s" ), acadErrorStatusText( es ) );
            return;
        }

        pPoly->highlight();
    }

    AcGePoint3d point;
    AcGePoint2d vertex;
    while(true)
    {
        ec = acedGetPoint( NULL, _T( "\nSelect vertex: " ), adsPoint );
        if(ec == RTCAN)
        {
            return;
        }

        point = asPnt3d( adsPoint );

        for(int i = 0; i < pPoly->numVerts(); i++)
        {
            pPoly->getPointAt( i, vertex );
            if(vertex.x == point.x && vertex.y == point.y)
            {
                pPoly->upgradeOpen();
                pPoly->removeVertexAt( i );
                pPoly->downgradeOpen();
                pPoly->draw();
                pPoly->highlight();
            }
        }
    }
}
1 REPLY 1
Message 2 of 2

Not exactly the same, but used transients to draw all vertexes.

Used code from here https://adndevblog.typepad.com/autocad/2012/04/using-transient-graphics.html

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


AutoCAD Beta