- 积分
- 1249
- 明经币
- 个
- 注册时间
- 2004-2-12
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
void Hyd_insertBlock2Cur(AcDbDatabase* pSourceDb,CString blockName) { CMemoryState oldMemState, newMemState, diffMemState; oldMemState.Checkpoint(); acDocManager->lockDocument(acDocManager->curDocument()); //写当前数据库之前一定要锁定 AcDbBlockTable* pSoureTable=NULL; AcDbObjectId idBlock; pSourceDb->getSymbolTable(pSoureTable, AcDb::kForRead); if (pSoureTable->getAt(blockName,idBlock)== Acad::eOk)//指定文件找到块 { pSoureTable->close(); AcDbDatabase * pOutputDb = new AcDbDatabase(Adesk::kTrue); pSourceDb->wblock(pOutputDb, idBlock); if (acdbCurDwg()->insert(idBlock,blockName,pOutputDb,true) != Acad::eOk) { delete pOutputDb; pOutputDb=NULL; return ; } delete pOutputDb; pOutputDb=NULL; AcDbBlockTableRecord* pMODELSPACE = NULL; AcDbBlockTable* pCurBlockTable=NULL; if (acdbCurDwg()->getSymbolTable(pCurBlockTable, AcDb::kForRead)!=Acad::eOk) { return ; } if (pCurBlockTable->getAt(ACDB_MODEL_SPACE,pMODELSPACE,AcDb::kForWrite)!=Acad::eOk) { pCurBlockTable->close(); return ; } if (pCurBlockTable->getAt(blockName,idBlock)!=Acad::eOk) { pCurBlockTable->close(); pMODELSPACE->close(); return ; } pCurBlockTable->close();
AcGeScale3d scale; scale[X]=1; scale[Y]=1; scale[Z]=1; AcGePoint3d basePoint; int retCode;
acedInitGet(NULL, NULL); acedAlert("选择插入点!"); retCode = acedGetPoint(NULL, NULL,asDblArray(basePoint)); switch(retCode) { case RTCAN : case RTNONE : basePoint.set(0.0, 0.0, 0.0); break; case RTNORM : break; case RTERROR : break; } AcDbBlockReference *pBR = new AcDbBlockReference; pBR->setBlockTableRecord(idBlock); pBR->setPosition(basePoint); pBR->setRotation(0); pBR->setScaleFactors(scale); if (pMODELSPACE->appendAcDbEntity(pBR)!=Acad::eOk) { delete pBR; pMODELSPACE->close(); return ; } pBR->close(); pMODELSPACE->close(); } else pSoureTable->close(); acDocManager->unlockDocument(acDocManager->curDocument()); //解除锁定 TRACE0("\n\ninsert is finishing!!\n\n"); newMemState.Checkpoint(); if( diffMemState.Difference( oldMemState, newMemState ) ) { TRACE( "Memory leaked!\n" ); } // 输出内存泄漏报告,显示在 Output 窗口的 Debug 页中 _CrtDumpMemoryLeaks();
}
我自己实在是检查不出来了。在CAD中反复操作插入图块都是好的,可是一关掉CAD,等一会就跳出了一个警告框了。估计是CAD关掉后,清理内存时,有申请的内存没有卸载掉的,各位帮忙看看吧 |
|