怎样将图块拷贝到另外一个图形文件中?
目的:从当前的图形文件拷贝已有图块到到另外一个图形文件中,并且在Model_space中创建一个图块引用:参数:szCurFileName:另外一个图形文件名,szBlockName:图块名,pSourceDatabase:当前图形文件的指针。
程序:
AcDbDatabase *pDb=new AcDbDatabase(Adesk::kFalse);<BR> if(pDb->readDwgFile(szCurFileName,_SH_DENYRW)==Acad::eOk)<BR> {<BR> AcDbObjectId newId;<BR> es=pDb->insert(newId,szBlockName,"Add"+szBlockName,pSourceDatabase);<BR> }
AcDbBlockTable *pTable;<BR> pDb->getBlockTable(pTable,AcDb::kForRead) ;<BR> AcDbObjectId oldId;<BR> if(pTable->getAt("Add"+szBlockName,oldId)==Acad::eOk)<BR> {<BR> AcDbBlockReference *pRef =new AcDbBlockReference;<BR> pRef->setBlockTableRecord(oldId);<BR> pRef->setPosition(AcGePoint3d(0,0,0));
AcDbBlockTableRecord *pModel;<BR> pTable->getAt(ACDB_MODEL_SPACE,pModel,AcDb::kForWrite);<BR> AcDbObjectId refId;<BR> es=pModel->appendAcDbEntity(refId,pRef);<BR> pRef->close();<BR> pModel->close();<BR> <BR> }<BR> pTable->close();<BR> delete pDb;
结果:打开szCurFileName所指的图,没有图块,也没有图块引用,怎么回事?
问题出在哪?
页:
[1]