Obtain the Visual Style/Shademode of a Viewport using ObjectARX

By Fenton Webb         Here’s a code snippet I use to get the Visual Style of a Viewport, mostly in my viewportDraw() callback… You have to obtain the Viewport object ID first, then use this code…              // paper space checks      AcDbObjectPointer viewportType(vpObjId, AcDb::kForRead);      if (viewportType.openStatus() == Acad::eOk)      {         TCHAR *visualStyleName = NULL;       AcDbDictUtil::getVisualStyleName(visualStyleName, viewportType->visualStyle());       acutPrintf(_T("nVisual Style = %s"), visualStyleName);         // free up the string         acutDelString(visualStyleName);      }      else      {       // model space       AcDbObjectPointer viewport(vpObjId, AcDb::kForRead);       if (viewport.openStatus() == Acad::eOk)       {          TCHAR *visualStyleName = NULL;          AcDbDictUtil::getVisualStyleName(visualStyleName, viewport->visualStyle());          acutPrintf(
_T("nVisual Style = %s"), visualStyleName);             // free up the string             acutDelString(visualStyleName);       }       else          acutPrintf(_T("nVisual Style = 2dWireframe"));      }
<p style="margin: 0px"><font face="Consolas"><font style="font-size: 8pt" color="#000000"></font></font></p> </div>

Comments

Leave a Reply

Discover more from Autodesk Developer Blog

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

Continue reading