插入外部图块时的错误,提示实体为空?????????
本帖最后由 作者 于 2005-3-10 13:12:13 编辑 <br /><br /> acDocManager->lockDocument( acDocManager->curDocument(), AcAp::kWrite, NULL, NULL,true) ; <BR>////////////////////////////////// <BR>AcDbObjectId id;<BR>AcDbObjectIdArray list;<BR>AcDbDatabase extDatabase( Adesk::kFalse );<BR>if (Acad::eOk != extDatabase.readDwgFile( "C:\\d.dwg")) //打开图库文件<BR>// if (Acad::eOk != extDatabase.readDwgFile( dwgName ))
{<BR> acedAlert( "Error reading DWG!" );<BR> return;<BR> }<BR> AcDbBlockTable* pBT;<BR> if (Acad::eOk != extDatabase.getSymbolTable( pBT, AcDb::kForRead ))<BR> {<BR> acedAlert( "Error getting BlockTable of DWG" );<BR> return;<BR> }<BR> AcDbBlockTableRecord* pBTR;<BR> Acad::ErrorStatus es = pBT->getAt( _T("bigblock"), pBTR, AcDb::kForRead );
//"bigblock"是要插入的块名<BR> pBT->close();<BR> if (Acad::eOk != es) {<BR> acedAlert( "Error getting the specific blockDef of DWG" );<BR> return;<BR> }
AcDbBlockReferenceIdIterator *pItr;<BR>if (Acad::eOk != pBTR->newBlockReferenceIdIterator(pItr))<BR>{<BR> acedAlert( "Error iterating" );<BR> pBTR->close();<BR> return;<BR>}
for (pItr->start(); !pItr->done(); pItr->step())<BR>{<BR> AcDbObjectId blkRefId;<BR> if (Acad::eOk == pItr->getBlockReferenceId(blkRefId))<BR> {<BR> list.append(blkRefId); <BR> break;<BR> } <BR>}<BR>delete pItr;<BR>pBTR->close();
if (list.isEmpty()) {<BR> acedAlert( "No entities found in model space of DWG" );<BR> return;<BR> }
AcDbDatabase *pTempDb;
if (Acad::eOk != extDatabase.wblock( pTempDb, list, AcGePoint3d::kOrigin ))<BR> {<BR> acedAlert( "wblock failed!" );<BR> return;<BR> }<BR> if (Acad::eOk != acdbHostApplicationServices()->workingDatabase()<BR> ->insert( AcGeMatrix3d::kIdentity, pTempDb ))<BR> acedAlert( "insert failed!" );
delete pTempDb;
// 如果不需要插入块参照,将模型空间中的最后一个对象删除即可<BR>ads_name lastEnt;<BR>if (acdbEntLast(lastEnt) != RTNORM)<BR>{<BR> acedAlert("获得模型空间最后一个实体失败!");<BR> return;<BR>}<BR>AcDbObjectId entId;<BR>es = acdbGetObjectId(entId, lastEnt);<BR>AcDbEntity *pEnt;<BR>es = acdbOpenAcDbEntity(pEnt, entId, AcDb::kForWrite);<BR>pEnt->erase();<BR>pEnt->close();<BR>//////////////////////////<BR>//用窗口的时候
acDocManager->unlockDocument( acDocManager->curDocument());//
<BR><BR><BR>
程序运行插入块时提示实体为空"No entities found in model space of DWG" ,应该是这里出错了,list.append(blkRefId); <BR> break;这两句没有执行,这是什么原因? pBTR中没有BlockReference,应将pBTR中的所有entity insert to curDb 楼上的可以说的更详细一点好吗? AcDbObjectId blkId = pBtRecord->objectId();<BR> //将块写到一临时数据库中<BR> AcDbDatabase *pTempDb;
extDatabase.wblock(pTempDb,blkId);<BR> 本帖最后由 作者 于 2005-3-10 16:08:18 编辑
谢谢楼上的兄弟,问题已解决!
程序只是把该图块插入到当前图形的块表中,怎样把该图块画到当前图形中呀???????? 刚刚开始学习ARX不就,请教楼主,如在当前图中何绘制该图块?
谢谢!QQ:19154480
页:
[1]