class ArxTemplate : public AcRxArxApp { inline static bool isInitialized = false; public: ArxTemplate() : AcRxArxApp() { } virtual AcRx::AppRetCode On_kInitAppMsg(void* pkt) { AcRx::AppRetCode retCode = AcRxArxApp::On_kInitAppMsg(pkt); //init app context return (retCode); } virtual AcRx::AppRetCode On_kUnloadAppMsg(void* pkt) { AcRx::AppRetCode retCode = AcRxArxApp::On_kUnloadAppMsg(pkt); return (retCode); } virtual AcRx::AppRetCode On_kLoadDwgMsg(void* pkt) override { AcRx::AppRetCode retCode = AcRxDbxApp::On_kLoadDwgMsg(pkt); initOnce(); return retCode; } virtual void RegisterServerComponents() { } bool initOnce() { if (!isInitialized) { isInitialized = true; //init document context } return isInitialized; } ... };