几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   ObjectARX(C++) (http://www.dimcax.com/hust/forumdisplay.php?f=34)
-   -   【转帖】插入块的问题,致命错误 (http://www.dimcax.com/hust/showthread.php?t=7670)

yang686526 2009-04-18 02:55 PM

【转帖】插入块的问题,致命错误
 
插入块的问题,致命错误
插入块的问题,致命错误
//设置好文件名称 插入点 插入角度 后调用此函数完成
void insertto_demo(cstring dwgfilename,acgepoint3d ptinsert ,float fangle)
{

acdbobjectid id;
acdbdatabase *pdatabase;
acdbdatabase *pdb;
pdatabase=new acdbdatabase(false);
hresult hr = s_ok;
hr=pdatabase->readdwgfile(basefunc->cstringtopchar(dwgfilename));
if (hr!=s_ok)
{
cstring strerror;
strerror.format("读取%s文件时出错!可能版本不匹配!",dwgfilename);
afxmessagebox(strerror);
return;
}
pdb=acdbhostapplicationservices()->workingdatabase();
pdb->insert(id,
basefunc->cstringtopchar(dwgfilename),pdatabase);
//delete pdatabase;
pdatabase=null;
acdbblocktable *ptable=null;
acdbhostapplicationservices()->workingdatabase()->getsymboltable(ptable,
acdb::kforread);

assert(ptable!=null);
acdbblocktablerecord *pmodelspace;
ptable->getat(acdb_model_space,pmodelspace,acdb::kforwrite);
ptable->close();
acdbblockreference *pblockref;
pblockref=new acdbblockreference(ptinsert,id);

pblockref->setrotation(fangle);
acgescale3d scale;
scale.sx=1;
scale.sy=1;
scale.sz=1;
pblockref->setscalefactors (scale);
pmodelspace->appendacdbentity(pblockref);
pmodelspace->close();
pblockref->close();
}
编译没有问题,运行时,只要到了要关闭当前的图纸时,就有问题,致命错误。
能保存能另存为。不能打开别的图纸,不能关闭当前图纸。
如果手动将插入的块删掉再关闭,还是有问题。
请高手帮忙


所有的时间均为北京时间。 现在的时间是 08:39 AM.