Toggling highlight state of an entity

By Balaji Ramamoorthy

Here is a sample ObjectARX code to toggle the highlight state of an entity.

static void ToggleHighlight(void)

{

    ads_point pick;

    ads_name ename;

 

    int ret = acedEntSel(

                        ACRX_T("Select an entity :"),

                        ename,

                        pick

                    );

    if ( RTNORM != ret)

        return;

 

    Acad::ErrorStatus es;

    AcDbObjectId entId = AcDbObjectId::kNull;

    es = acdbGetObjectId( entId, ename );

    if ( Acad::eOk != es)

        return;

 

    AcDbEntity *pEnt = NULL;

    es = acdbOpenAcDbEntity (    pEnt,

                                entId,

                                AcDb::kForRead

                            );

 

    if ( Acad::eOk != es)

        return;

 

    AcDbFullSubentPath subPath;

    AcGiHighlightStyle hs = pEnt->highlightState(subPath);

 

    if(hs == AcGiHighlightStyle::kAcGiHighlightNone)

    {// Entity is not highlighted, lets highlight

        pEnt->highlight();

    }

    else

    {// Entity is already highlighted, lets unhighlight

        pEnt->unhighlight();

    }

    pEnt->close();

}


Comments

One response to “Toggling highlight state of an entity”

  1. petcon Avatar
    petcon

    what these code for?

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading