AcDbDatabase* CUlity::NewDocDatabase() { AcDbDatabase* pNewDb=NULL; static char pData[] ="acad.dwt"; //acDocManager->executeInApplicationContext(CreateDoc, (void *)pData); //acDocManager->newDocument(); if(acDocManager->isApplicationContext()) { acDocManager->appContextNewDocument((const char *)pData); } else acutPrintf("\nERROR To Create Doc!\n"); pNewDb=GetLastDoc()->database(); if(!pNewDb) return NULL; return pNewDb; } AcApDocument* CUlity::GetLastDoc() { AcApDocument* documentArray[10];
AcApDocument* pDoc; AcApDocumentIterator* pDocIter; int nDocs = 0;; pDocIter = acDocManager->newAcApDocumentIterator(); for ( ; !pDocIter->done(); pDocIter->step(), nDocs++) { pDoc = pDocIter->document(); documentArray[nDocs] = pDoc; acutPrintf("%d. %s\n", nDocs + 1, pDoc->fileName()); } delete pDocIter; if (nDocs>0) { return documentArray[nDocs - 1]; } else { return NULL; } } 这样获取的Database就对了, |