- UID
- 211977
- 积分
- 61
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2005-1-17
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
acDocManager->lockDocument( acDocManager->curDocument(), AcAp::kWrite, NULL, NULL,true) ;
//////////////////////////////////
AcDbObjectId id;
AcDbObjectIdArray list;
AcDbDatabase extDatabase( Adesk::kFalse );
if (Acad::eOk != extDatabase.readDwgFile( "C:\\d.dwg")) //打开图库文件
// if (Acad::eOk != extDatabase.readDwgFile( dwgName ))
{
acedAlert( "Error reading DWG!" );
return;
}
AcDbBlockTable* pBT;
if (Acad::eOk != extDatabase.getSymbolTable( pBT, AcDb::kForRead ))
{
acedAlert( "Error getting BlockTable of DWG" );
return;
}
AcDbBlockTableRecord* pBTR;
Acad::ErrorStatus es = pBT->getAt( _T("bigblock"), pBTR, AcDb::kForRead );
//"bigblock"是要插入的块名
pBT->close();
if (Acad::eOk != es) {
acedAlert( "Error getting the specific blockDef of DWG" );
return;
}
AcDbBlockReferenceIdIterator *pItr;
if (Acad::eOk != pBTR->newBlockReferenceIdIterator(pItr))
{
acedAlert( "Error iterating" );
pBTR->close();
return;
}
for (pItr->start(); !pItr->done(); pItr->step())
{
AcDbObjectId blkRefId;
if (Acad::eOk == pItr->getBlockReferenceId(blkRefId))
{
list.append(blkRefId);
break;
}
}
delete pItr;
pBTR->close();
if (list.isEmpty()) {
acedAlert( "No entities found in model space of DWG" );
return;
}
AcDbDatabase *pTempDb;
if (Acad::eOk != extDatabase.wblock( pTempDb, list, AcGePoint3d::kOrigin ))
{
acedAlert( "wblock failed!" );
return;
}
if (Acad::eOk != acdbHostApplicationServices()->workingDatabase()
->insert( AcGeMatrix3d::kIdentity, pTempDb ))
acedAlert( "insert failed!" );
delete pTempDb;
// 如果不需要插入块参照,将模型空间中的最后一个对象删除即可
ads_name lastEnt;
if (acdbEntLast(lastEnt) != RTNORM)
{
acedAlert("获得模型空间最后一个实体失败!");
return;
}
AcDbObjectId entId;
es = acdbGetObjectId(entId, lastEnt);
AcDbEntity *pEnt;
es = acdbOpenAcDbEntity(pEnt, entId, AcDb::kForWrite);
pEnt->erase();
pEnt->close();
//////////////////////////
//用窗口的时候
acDocManager->unlockDocument( acDocManager->curDocument());//
程序运行插入块时提示实体为空"No entities found in model space of DWG" ,应该是这里出错了,list.append(blkRefId);
break;这两句没有执行,这是什么原因? |
|