CAD创建一个新的图形文件
static void linea(void) { AcDbDatabase *pDb = new AcDbDatabase(true, false); AcGePoint3d pickPoint; AcGePoint3d p1(0, 0, 0); AcGePoint3d p2(100, 100, 0); AcDbLine *line = new AcDbLine(p1, p2); AcDbBlockTable *pBt = NULL; acdbHostApplicationServices()->workingDatabase()->getBlockTable( pBt,AcDb::kForRead); AcDbBlockTableRecord *pBtr = NULL; pBt->getAt(ACDB_MODEL_SPACE, pBtr, AcDb::kForWrite); AcDbObjectId lineId,pTextId; struct resbuf *Xdata = acutBuildList(AcDb::kDxfRegAppName, "test", AcDb::kDxfXdAsciiString, TEXT("字符串测试数据"), AcDb::kDxfXdInteger32, 2, AcDb::kDxfXdReal, 3.14, AcDb::kDxfXdWorldXCoord, asDblArray(pickPoint), RTNONE); line->setXData(Xdata); pBtr->appendAcDbEntity(lineId, line); AcDbText *pText = new AcDbText(p1, "xiongzhihui"); pBtr->appendAcDbEntity(pTextId, pText); CString name = "C:\\123.dwg"; acutPrintf(_T(name)); pDb->saveAs(name); pBt->close(); pBtr->close(); line->close(); pText->close(); delete pDb;
新建一个图形数据库 然后saveas路径