您说的没错,正是锁定和解锁文档的问题,现将调试好的源码贴出来:
acDocManager->lockDocument(acDocManager->curDocument(), AcAp::kWrite, NULL, NULL, true); //锁定文档
AcGePoint3d ptStart(0, 0, 0);
AcGePoint3d ptEnd(100, 100, 0);
AcDbLine *pLine = new AcDbLine(ptStart, ptEnd);
AcDbBlockTable *pBlockTable;
acDocManager->curDocument()->database()->getBlockTable(pBlockTable, AcDb::kForRead);
//acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlockTable, AcDb::kForRead);
AcDbBlockTableRecord *pBlockTableRecord;
pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord,AcDb::kForWrite);
AcDbObjectId lineId;
pBlockTableRecord->appendAcDbEntity(lineId, pLine);
pBlockTable->close();
pBlockTableRecord->close();
pLine->close();
acDocManager->unlockDocument(acDocManager->curDocument()); //解锁文档
return S_OK;
页:
1
[2]