By Adam Nagy
When on a paper layout, if a viewport is selected or is active then the AutoCAD status bar contains a button that enables the user to synchronize the viewport’s scale with the annotation scale.
You can achieve the same using the below code:
ads_name name;
ads_point pt;
acedEntSel(L"Pick viewport", name, pt);
AcDbObjectId id;
acdbGetObjectId(id, name);
AcDbObjectPointer<AcDbViewport> ptrVP(id, AcDb::kForWrite);
AcDbAnnotationScale * pAnnoScale = ptrVP->annotationScale();
double scale;
pAnnoScale->getScale(scale);
delete pAnnoScale;
ptrVP->setCustomScale(scale);