马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 1121443108qaz 于 2018-9-19 23:44 编辑
我这样加为什么一点用都没有,我觉得是我没初始化好,可是网上或书上的教程都有点老了,这是arx2019的,怎么加啊。
 - //头
- class CDbReatorUtil :
- public AcDbDatabaseReactor
- {
- public:
- CDbReatorUtil();
- ~CDbReatorUtil();
- virtual void objectAppended(const AcDbDatabase* dwg, const AcDbObject* dbObj);
- };
- //源
- CDbReatorUtil::CDbReatorUtil()
- {
- }
- CDbReatorUtil::~CDbReatorUtil()
- {
- }
- void CDbReatorUtil::objectAppended(const AcDbDatabase* dwg, const AcDbObject* dbObj)
- {
- if (dbObj->isKindOf(AcDbEntity::desc()))
- {
- AcDbEntity* pEnt = AcDbEntity::cast(dbObj);
- pEnt->upgradeOpen();
- pEnt->setColorIndex(1);
- }
- //这里我尝试过直接acutprintf(L"\n新建了一个物体")也没用
- }
- //以下是acrxentrypoint.cpp的内容
- CDbReatorUtil *pDbreator = NULL;
- class CnewApp : public AcRxArxApp {
- public:
- CnewApp () : AcRxArxApp () {}
-
- virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt) {
- AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ;
- if (pDbreator==NULL)
- {
- pDbreator = new CDbReatorUtil();
- }
- return (retCode) ;
- }
- virtual AcRx::AppRetCode On_kUnloadAppMsg (void *pkt)
- {
- AcRx::AppRetCode retCode =AcRxArxApp::On_kUnloadAppMsg (pkt) ;
- if (pDbreator!=NULL)
- {
- delete pDbreator;
- pDbreator = NULL;
- }
- return (retCode) ;
- }
- }
2018.9.19 初始化更改为如下代码成功
 - class CxxxApp : public AcRxArxApp {
- public:
- CxxxApp () : AcRxArxApp () {}
- virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt) {
- // TODO: Load dependencies here
- // You *must* call On_kInitAppMsg here
- AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ;
- // TODO: Add your initialization code here
- return (retCode) ;
- }
- virtual AcRx::AppRetCode On_kUnloadAppMsg (void *pkt) {
- // TODO: Add your code here
- // You *must* call On_kUnloadAppMsg here
- AcRx::AppRetCode retCode =AcRxArxApp::On_kUnloadAppMsg (pkt) ;
- //deleteAcRxClass(CDbReatorUtil::desc());
- // TODO: Unload dependencies here
- return (retCode) ;
- }
- virtual AcRx::AppRetCode On_kLoadDwgMsg(void *pkt)
- {
- if (pDbreator==NULL)
- {
- pDbreator = new CDbReatorUtil();
- AcDbDatabase* pdata = acdbHostApplicationServices()->workingDatabase();
- if (pdata)
- {
- pdata->addReactor(pDbreator);
- }
- }
- else
- {
- acutPrintf(L"\n未获得当前数据库指针");
- }
- return AcRx::kRetOK;
- }
- virtual AcRx::AppRetCode On_kUnloadDwgMsg(void* pkt)
- {
- if (pDbreator != NULL)
- {
- acdbHostApplicationServices()->workingDatabase()->removeReactor(pDbreator);
- delete pDbreator;
- pDbreator = NULL;
- }
- return AcRx::kRetOK;
- }
- }
|