几何尺寸与公差论坛------致力于产品几何量公差标准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)
-   -   【转帖】取块名后出错,cad退出。 (http://www.dimcax.com/hust/showthread.php?t=7211)

yang686526 2009-04-16 09:18 PM

【转帖】取块名后出错,cad退出。
 
取块名后出错,cad退出。
取块名后出错,cad退出。
//get tag and tagstring of special block
//(vlb-getatts (car (entsel)))
static int vxgetatts_comd(resbuf *rb)
{
ads_name ent;
ads_name_set(pm[0]->resval.rlname, ent);
acdbobjectid entid;
acad::errorstatus es = acdbgetobjectid(entid, ent);
if (es != acad::eok)
{
acutprintf(_t("\ncann't get objid"));
return rtnorm;
}
acdbentity *pent = null;
es = acdbopenacdbentity(pent, entid, acdb::kforread);
if(es != acad::eok)
{
acutprintf(_t("\nobject is not opened!"));
return rtnorm;
}
lpctstr hande = _t("b3");
acdbhandle hdl;
pent->getacdbhandle(hdl);
tchar szhandle[17];
hdl.getintoasciibuffer(szhandle);
hande = (lpctstr)szhandle;
pent->close();
iacaddatabase idatabase;
iacadapplication iapp;
iacaddocument idoc;
iacadmodelspace imspace;

iacadobject iobject;
iacadblockreference iblkref;
idispatch *pdisp = acedgetacadwinapp()->getidispatch(true);
iapp.attachdispatch(pdisp);
pdisp = iapp.getactivedocument();
idoc.attachdispatch(pdisp);
pdisp = idoc.getmodelspace();
imspace.attachdispatch(pdisp);
iobject = (iacadobject)idoc.handletoobject(hande);
_bstr_t objname;
objname = iobject.getobjectname();
if (lstrcmpi(objname, _t("acdbblockreference")) == 0)
{
_bstr_t blkname, blkhand;
// iblkref.attachdispatch(iobject);
iblkref = (iacadblockreference)iobject;
blkname = iblkref.getname(); afxmessagebox(blkname, mb_ok); //此句显示块名后退出cad
}

return rtnorm;
}
已解决!
改为autocad::iacadobjectptr iobject;就可以了。


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