comejava 发表于 2005-3-10 12:09:00

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

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;这两句没有执行,这是什么原因?

uparrow 发表于 2005-3-10 13:42:00

pBTR中没有BlockReference,应将pBTR中的所有entity insert to curDb

comejava 发表于 2005-3-10 14:03:00

楼上的可以说的更详细一点好吗?

uparrow 发表于 2005-3-10 14:58:00

AcDbObjectId blkId = pBtRecord->objectId();
        //将块写到一临时数据库中
        AcDbDatabase *pTempDb;
        extDatabase.wblock(pTempDb,blkId);

comejava 发表于 2005-3-10 15:06:00


谢谢楼上的兄弟,问题已解决! 程序只是把该图块插入到当前图形的块表中,怎样把该图块画到当前图形中呀????????

freejustin 发表于 2005-4-8 10:34:00

刚刚开始学习ARX不就,请教楼主,如在当前图中何绘制该图块?
谢谢!QQ:19154480
页: [1]
查看完整版本: 插入外部图块时的错误,提示实体为空?????????