几何尺寸与公差论坛------致力于产品几何量公差标准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=7316)

yang686526 2009-04-16 10:32 PM

【转帖】大虾帮忙看看程序吧
 
大虾帮忙看看程序吧
大虾帮忙看看程序吧
整个程序主要是为了从dwg文件中得到图块的包罗矩形的两个点.(不知道有没有其他的方法)
下面怎么老是得不到 包络矩形的两个点呢?
只会得到**error on get the extents point...
不知道是那里出问题了?大虾们帮忙看看吧
//插入图形

acad::errorstatus es;
cstring filename="e:\\autocad\\dwgfile\\qq.dwg";//已经存在的文件
acdbdatabase *pnewdb=new acdbdatabase(adesk::kfalse);
es=pnewdb->readdwgfile(filename,_sh_denyno,false);
if(es!=acad::eok)
{
acutprintf("\nthe file %s cannot be opend",filename);
return;
}

acdbdatabase *pdb;
pdb=acdbhostapplicationservices()->workingdatabase();
cstring pblockname="testblock";
acdbobjectid blockid;

if((es=pdb->insert(blockid, pblockname,pnewdb,true))==acad::eok)
{ acutprintf("\ninsert ok\n");
delete pnewdb;}
else
{ afxmessagebox("insert failed");
delete pnewdb;
return; }

acgepoint3d pt(100.0,
你这种好象要通过事务处理才能实现
哦,可是必须要事务处理吗?
不能把图块读到当前数据库中,再对图块操作吗?
好了,问题解决了。这样就得到了。谢谢easypower 的答复
acad::errorstatus es;
cstring filename="e:\\autocad\\dwgfile\\qq.dwg";//已经存在的文件
acdbdatabase *pnewdb=new acdbdatabase(adesk::kfalse);
es=pnewdb->readdwgfile(filename,_sh_denyno,false);
if(es!=acad::eok)
{
acutprintf("\nthe file %s cannot be opend",filename);
return;
}

acdbdatabase *pdb;
pdb=acdbhostapplicationservices()->workingdatabase();
cstring pblockname="testblock";
acdbobjectid blockid;

if((es=pdb->insert(blockid, pblockname,pnewdb,true))==acad::eok)
{ acutprintf("\ninsert ok\n");
delete pnewdb;}
else
{ afxmessagebox("insert failed");
delete pnewdb;
return; }
//
acdbextents exts;
//
acdbblockreference *pblkref = new acdbblockreference;
pblkref->setblocktablerecord(blockid);//指向blockid;
//
pblkref->getgeomextents(exts);
acutprintf("\nthe maxpoint=%0.4f,%0.4f",exts.maxpoint()[x],exts.maxpoint()[y]);
acutprintf("\nthe minpoint=%0.4f,%0.4f",exts.minpoint()[x],exts.minpoint()[y]);
//
pblkref->close();

不过,如果程序这样写
if(pblkref->getgeomextents(exts)!=acad::eok)
{
acutprintf("\nerror\n");
}
if中的语句会是“假”,得到error,不知道为什么啊?


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