- UID
- 200222
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2004-12-6
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
在非模态对话框中一个按钮,点击该按钮时,需要打cad的数据库进行相应的块插入操作.可是,为什么运行到打开数据库时就出错. 在模态对话框中是可以打开cad数据库的. 还请各位指点!
void CElemInsertDlg::OnButtonNext()
{
// TODO: Add your control notification handler code here
nCount=m_SldList.GetCount();
if (nIndex<nCount-1)
{
nIndex++;
ShowSld(nIndex);
acutPrintf("\nnIndex=%d",nIndex);
acutPrintf("\n%s",sldPath);
//得到块名
CString name,temp;
int len=sldPath.GetLength();
int start=sldPath.ReverseFind('\\');
temp=sldPath.Right(len-start-1);
name=temp.Left(len-start-5);
acutPrintf("\n%s\n",name);
AcDbBlockTable *BlockTable ;
Acad::ErrorStatus es=acdbHostApplicationServices()- >workingDatabase()->
getSymbolTable(BlockTable,AcDb::kForWrite);
if (es!=Acad::eOk)
{
acutPrintf("\nFail Open BlockTable!\n");
//----------------------每次运行到这里就出错,为什么????-----------------------------
return;
}
BlockTable->close();
AcDbObjectId blockId ;
if ( BlockTable->has (name) != Adesk::kTrue )
{
acutPrintf("\n没有块 %s\n",name);
BlockTable->close () ;
AcDbDatabase *pDwg =new AcDbDatabase (Adesk::kFalse) ;
char buffer[100];
sprintf( buffer, "%s", dwgPath );
acutPrintf("\n%s",buffer);
es=pDwg->readDwgFile (buffer);
if (es!= Acad::eOk )
{
acutPrintf ("\n读取dwg文件失败!\n") ;
return;
}
es=acdbHostApplicationServices()->workingDatabase()->
insert(blockId,name,pDwg,Adesk::kFalse);
if ( es != Acad::eOk )
{
acutPrintf ("\n插入块错误.\n") ;
return;
}
delete pDwg ;
}
else
{
acutPrintf("\n存在块 %s",name);
BlockTable->getAt (name, blockId, false) ;
BlockTable->close () ;
} |
|