static void ArxProject1docnew(void)
{
acutPrintf(_T("/ndocnew!"));
AcDbDatabase *pDb = acdbCurDwg();
createDwg(pDb);
newDoc();
}
void
createDwg(AcDbDatabase *&pDb)
{
// AcDbDatabase *pDb = new AcDbDatabase();
AcDbBlockTable *pBtbl;
pDb->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();
// AcDbDatabase::saveAs() does NOT automatically
// append a DWG file extension, so it
// must be specified.
pDb->saveAs(_T("c://test1.dwg"));
}
Acad::ErrorStatus newDoc(CString dwgpath)
{
Acad::ErrorStatus result = Acad::eOk;
if(acDocManager->isApplicationContext())
{
result = acDocManager->appContextNewDocument(dwgpath);
if(result != Acad::eOk)
acutPrintf(CString(_T("ERROR: ")) + acadErrorStatusText(result));
}
else
acDocManager->executeInApplicationContext(NewDocHelper, &dwgpath);
return result;
}
void NewDocHelper(void *pData)
{
Acad::ErrorStatus result ;
if(acDocManager->isApplicationContext())
{
CString* dwg = (CString*)pData;
result = acDocManager->appContextNewDocument(*dwg);
if(result != Acad::eOk)
acutPrintf(CString(_T("ERROR: ")) + acadErrorStatusText(result));
}
else
acutPrintf(CString(_T("ERROR: in Document context :")) + acDocManager->curDocument()->fileName());
}