Highlighting Attributes doesn’t work when using the highlight() method in ObjectARX

<?xml encoding=”UTF-8″>By Fenton Webb

Issue

When I call pAttribute->highlight(); it returns Acad::eOk but the attribute is not highlighted on screen.

I have also tried opening the block reference and highlighting the attribute via:

AcDbFullSubentPath subPath;
subPath.objectIds().append(pAttribute->id());
blkRef->highlight(subPath);
this method highlights the block reference and all attributes.

Is there any way to highlight only the attribute?

Solution

There is a defect which prevents the AcDbAttribute::highlight() from working correctly.

Here is a workaround…

<p>//////////////////////////////////////////////////////////////////////////////<br>// This is command 'TEST, by Fenton Webb [Mar/11/2002], DevTech, Autodesk<br>void asdktest()<br>{<br> ads_name ename;<br> ads_point pt;<br> // pick an entity to check<br> int res = acedEntSel (_T("nPick a block with attributes : "), ename, pt);<br> // if the user didn't cancel<br> if (res == RTNORM)<br> {<br>  AcDbObjectId objId;<br>  // convert the ename to an object id<br>  acdbGetObjectId (objId, ename);<br>  // open the entity for read<br>  AcDbObjectPointer<AcDbBlockReference>blockRef (objId, AcDb::kForRead);<br>  // if ok<br>  if (blockRef.openStatus () == Acad::eOk)<br>  {<br>   // create an attribute iterator so we can check to see if any attribute asre attached<br>   AcDbObjectIterator *pAttributeIterator = blockRef->attributeIterator ();<br>   // if it allocated ok<br>   if (pAttributeIterator != NULL)<br>   {                    <br>    AcDbObjectId   ObjId;<br>    AcDbAttribute *pAttribute = NULL;          <br>    // now loop through them<br>    for (int count=0; !pAttributeIterator->done(); pAttributeIterator->step(), ++count)<br>    {<br>     // get the object id of the attribute<br>     acdbGetAdsName(ename, pAttributeIterator->objectId());<br>     <br>     // highlight every other one<br>     if (!(count % 2))<br>     {<br>      // try and highlight it<br>      acedRedraw (ename, 3);<br>     }<br>    }<br>    // delete the iterator<br>    delete pAttributeIterator;<br>   }<br>  }<br>  else<br>  {<br>   AfxMessageBox(_T("This is not a block reference"));<br>  }<br> }<br>}</p>

Comments

Leave a Reply

Discover more from Autodesk Developer Blog

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

Continue reading