请教个关于事务处理的问题
如何实现批量图纸的文字样式替换,参考网上的文字替换不能实现。http://bbs.mjtd.com/xwb/images/bgimg/icon_logo.png 该贴已经同步到 包装纸袋公司的微博 本帖最后由 包装纸袋公司 于 2015-8-19 07:44 编辑
void CSTApp ::AAASTST(void)
{
CString openStr;
CFileDialog fileDia(true,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,_T("CAD(*.dwg)|*.dwg|DXF(*.dxf|*.dxf"));
if(fileDia.DoModal()!= IDOK)
return ;
openStr=fileDia.GetPathName();
AcDbDatabase *pDb;
pDb=new AcDbDatabase(Adesk::kFalse);
pDb->readDwgFile(openStr.GetBuffer(0));
openStr.ReleaseBuffer();
AcDbTextStyleTable *pTeSty;
pDb->getTextStyleTable(pTeSty,AcDb::kForRead);
AcDbTextStyleTableIterator *pTxtIter;
pTeSty->newIterator(pTxtIter);
AcDbObjectIdArray ArrId;
for (pTxtIter->start();!pTxtIter->done();pTxtIter->step())
{ AcDbTextStyleTableRecord *pTextRecord;
pTxtIter->getRecord(pTextRecord,AcDb::kForRead);
ArrId.append(pTextRecord->objectId());
pTextRecord->close();
}
delete pTxtIter;
pTeSty->close();
AcDbBlockTable *pThisTable;
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pThisTable,AcDb::kForWrite);
AcDbObjectId id=pThisTable->objectId();
pThisTable->close();
AcDbObjectId tranId;
AcDbIdMapping errorMap;
acapLongTransactionManagerPtr()->checkOut(tranId,ArrId,id,errorMap);
AcDbObject *pObject;
if(acdbOpenObject(pObject,tranId,AcDb::kForRead) !=Acad::eOk)//在这一步打开失败,查看资料说checkOut只对块表记录,那么对应符号表如何操作。
{
AfxMessageBox(_T("pObject"));
return;
}
AcDbLongTransaction *pLongTrn=AcDbLongTransaction::cast(pObject);
if(pLongTrn == NULL)
{
AfxMessageBox(_T("pLongTrn"));
pObject->close();
return;
}
AcDbLongTransWorkSetIterator *pWorkItr;
pLongTrn->newWorkSetIterator(pWorkItr);
for(pWorkItr->start();!pWorkItr->done();pWorkItr->step())
{
AcDbObject *pEnt;
acdbOpenAcDbObject(pEnt,pWorkItr->objectId(),AcDb::kForWrite);
AcDbTextStyleTableRecord *pText= AcDbTextStyleTableRecord::cast(pEnt);
pText->setXScale(14);
pEnt->close();
}
delete pWorkItr;
pObject->close();
acapLongTransactionManagerPtr()->checkIn(tranId,errorMap);
pDb->saveAs(openStr);
delete pDb;
页:
[1]