- UID
- 16948
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-11-24
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
编译通过(为什么运行重视出现对话框‘读写错误“
谢指点)dys-cj@home.ncidi.com...
原程序如下:
- [font=courier new]
- CString fname=getfilename.file1;
- CString addintional="d:\";
- fname=addintional+fname+".dwg";
- //additional prase
- //
- acutPrintf("fname.....%s\n",fname);
- //end.cj
- AcDbDatabase* pDb;
- AcDbObjectId transId;
- pDb = new AcDbDatabase(Adesk::kFalse);
- pDb->readDwgFile(fname);
- if (pDb->readDwgFile(fname) != Acad::eOk)
- {
- acutPrintf("\nSorry, that draing is probably already open.\n");
- return;
- }
- // Get the Block Table and then the model space record.
- //
- AcDbBlockTable *pBlockTable;
- pDb->getSymbolTable(pBlockTable, AcDb::kForRead);
- AcDbBlockTableRecord *pOtherMsBtr;
- pBlockTable->getAt(ACDB_MODEL_SPACE, pOtherMsBtr, AcDb::kForRead);
- pBlockTable->close();
- // Create an iterator.
- //
- AcDbBlockTableRecordIterator *pIter;
- pOtherMsBtr->newIterator(pIter);
- // Set up an object ID array.
- //
- AcDbObjectIdArray objIdArray;
- // Iterate over the model space BTR. Look specifically
- // for lines and append their object ID to the array.
- //
- for (pIter->start(); !pIter->done(); pIter->step())
- {
- AcDbEntity *pEntity;//AcDbText *pEntitytext;
- pIter->getEntity(pEntity, AcDb::kForRead);
- // Look for only AcDbLine objects and add them to the
- // object ID array.
- //
- if (pEntity->isKindOf(AcDbText::desc()))
- {
- objIdArray.append(pEntity->objectId());
- }
- // pEntitytext->close();
- acutPrintf("111d\n");
- pEntity->close();
- }
- delete pIter;
- pOtherMsBtr->close();
- if (objIdArray.isEmpty())
- {
- //acutPrintf("\nYou must pick a drawing file that contains lines.");
- return;
- }
- // Now get the current database and the object ID for the
- // current database's model space BTR.
- //
- AcDbBlockTable *pThisBlockTable;
- acdbHostApplicationServices()->workingDatabase()
- ->getSymbolTable(pThisBlockTable, AcDb::kForRead);
- AcDbBlockTableRecord *pThisMsBtr;
- pThisBlockTable->getAt(ACDB_MODEL_SPACE, pThisMsBtr, AcDb::kForWrite);
- pThisBlockTable->close();
- AcDbObjectId id = pThisMsBtr->objectId();
- pThisMsBtr->close();
- // Create the long transaction. This will check all the entities
- // out of the external database.
- //
- AcDbIdMapping errorMap;
- acapLongTransactionManagerPtr()->checkOut(transId, objIdArray, id, errorMap);
- // Now modify the color of these entities.
- //
- AcDbObject* pObj;
- //w .by.cj
- //w.by.cj
- if (acdbOpenObject(pObj, transId, AcDb::kForRead) == Acad::eOk)
- {
- AcDbLongTransaction* pLongTrans = AcDbLongTransaction::cast(pObj);
- if (pLongTrans != NULL)
- {
- // Get a work set iterator.
- //
- AcDbLongTransWorkSetIterator* pWorkSetIter;
- pLongTrans->newWorkSetIterator(pWorkSetIter);
- //add///cj
-
- for (pWorkSetIter->start(); !pWorkSetIter->done(); pWorkSetIter->step())
- {
- AcDbText *pEntity;
- acdbOpenObject(pEntity, pWorkSetIter->objectId(), AcDb::kForWrite);
- //假如语句
- if(pEntity->textString()=="yyy"
- {
- pEntity->setTextString("xxx");
- }
- pEntity->close();
- }
- delete pWorkSetIter;
- }
- pObj->close();
- }
- acapLongTransactionManagerPtr()->checkIn(transId, errorMap);
- pDb->saveAs(fname);
- delete pDb;
- pDb = NULL;
- acutPrintf("ddd,end....%s",fname);
- // acad_free(fname);
- }
- [/font]
复制代码 |
|