AcDbDatabase* CCreateEnity::NewDocDatabase() {
AcDbDatabase* pNewDb=NULL; static ACHAR pData[] =L"acad.dwt"; acDocManager->executeInApplicationContext(CreateDoc,(void *)pData); 为什么执行这句后下面语句不执行,只有回到cad切换回原来的文档才响应而且运行到实体关闭(绿色字体)报错,貌似数据库没有切换,该怎么改呢?有什么书或资料,高手们指点一下,谢谢! AcApDocument* npDoc=GetLastDoc(); acDocManager->activateDocument(npDoc); pNewDb=npDoc->database(); if(!pNewDb) return NULL; acDocManager->setCurDocument(npDoc); /* acdbHostApplicationServices()->setWorkingDatabase(pNewDb);*/ /*pNewDb=acdbHostApplicationServices()->workingDatabase(); */ AcDbBlockTable *pBtbl; pNewDb->getSymbolTable(pBtbl, AcDb::kForRead); AcDbBlockTableRecord *pBtblRcd; pBtbl->getAt(ACDB_MODEL_SPACE, pBtblRcd, AcDb::kForWrite); pBtbl->close(); AcDbCircle *pCir1 = new AcDbCircle(AcGePoint3d(1,1,1), AcGeVector3d(0,0,1), 1.0), *pCir2 = new AcDbCircle(AcGePoint3d(4,4,4), AcGeVector3d(0,0,1), 2.0); pBtblRcd->appendAcDbEntity(pCir1); pCir1->close();
pBtblRcd->appendAcDbEntity(pCir2); pCir2->close(); pBtblRcd->close(); delete pNewDb; return pNewDb; } void CreateDoc( void *pData) { AcApDocument* pDoc = acDocManager->curDocument(); if (acDocManager->isApplicationContext()) { acDocManager->appContextNewDocument((const ACHAR *)pData); } } |