明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2570|回复: 5

插入外部图块时的错误,提示实体为空?????????

[复制链接]
发表于 2005-3-10 12:09:00 | 显示全部楼层 |阅读模式
本帖最后由 作者 于 2005-3-10 13:12:13 编辑

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;这两句没有执行,这是什么原因?
发表于 2005-3-10 13:42:00 | 显示全部楼层
pBTR中没有BlockReference,应将pBTR中的所有entity insert to curDb
 楼主| 发表于 2005-3-10 14:03:00 | 显示全部楼层
楼上的可以说的更详细一点好吗?
发表于 2005-3-10 14:58:00 | 显示全部楼层
AcDbObjectId blkId = pBtRecord->objectId();
//将块写到一临时数据库中
AcDbDatabase *pTempDb; extDatabase.wblock(pTempDb,blkId);
 楼主| 发表于 2005-3-10 15:06:00 | 显示全部楼层
本帖最后由 作者 于 2005-3-10 16:08:18 编辑

谢谢楼上的兄弟,问题已解决!



程序只是把该图块插入到当前图形的块表中,怎样把该图块画到当前图形中呀????????
发表于 2005-4-8 10:34:00 | 显示全部楼层
刚刚开始学习ARX不就,请教楼主,如在当前图中何绘制该图块?


谢谢!QQ:19154480
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-2-21 19:23 , Processed in 0.183437 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表