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<AcDbViewport> 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<AcDbViewportTableRecord> 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"));
}