- 积分
- 603
- 明经币
- 个
- 注册时间
- 2015-7-30
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2015-8-19 07:43:19
|
显示全部楼层
本帖最后由 包装纸袋公司 于 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;
|
|