- UID
- 211977
- 积分
- 61
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2005-1-17
- 最后登录
- 1970-1-1
|
发表于 2005-3-4 16:40:51
|
显示全部楼层
AcDbDatabase *pDwg =new AcDbDatabase (Adesk::kFalse) ;
Acad::ErrorStatus es;
es=pDwg->readDwgFile ("C:\\c.dwg") ;
if(es==Acad::eOk)
{
AfxMessageBox("readDwgFile Successful!");
//return;
}
AcDbObjectId blockId ;
es = acdbHostApplicationServices()->workingDatabase()->insert(blockId, LPCTSTR(""), pDwg);
if ( es != Acad::eOk )
AfxMessageBox ("插入块错误.") ;
delete pDwg ;
AcDbObjectId idBlock;
AcDbBlockReference* pBlock=new AcDbBlockReference ;
AcGePoint3d ptCenter=AcGePoint3d(0,0,0);
pBlock->setPosition(ptCenter);
pBlock->setBlockTableRecord(blockId);
AcDbDatabase* pDb=NULL;
AcDbObjectId idNew=AcDbObjectId::kNull;
if(pDb==NULL)
pDb=acdbHostApplicationServices()->workingDatabase();
AcDbBlockTable *pTable=NULL;
Acad::ErrorStatus Error=pDb->getBlockTable(pTable, AcDb::kForRead);
if(pTable==NULL)
{
AfxMessageBox("块表打开错误!");
return;
}
AcDbBlockTableRecord *pRecord=NULL;
Error=pTable->getAt(ACDB_MODEL_SPACE,pRecord,AcDb::kForWrite);
pTable->close();
if(pRecord==NULL)
{
AfxMessageBox("块纪录打开错误!");
return;
}
Error=pRecord->appendAcDbEntity(idBlock,pBlock);
pRecord->close();
pBlock->close(); |
|