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

yang686526 2009-04-16 04:35 PM

【转帖】[求助]怎样提取块属性
 
[求助]怎样提取块属性
[求助]怎样提取块属性
我想在arx提取明细表项属性值(每一行记录事先定义为块),包括材料,名称,重量等信息,如何实现,各位大哥请给点提示,先行谢过!
自己解决了
提取自定义属性块信息,我已经解决了,呵呵
等我整理好了,再发上来
楼主快贴上来吧
给大家参考一下
以下代码实现自定义属性块的属性值提取,我采用鼠标拾取的方式从打开的图形文件中指定块(注意块中要有自己定义的属性)注释部分代码是我基于acui对话框实现的,根据你的具体情况选择吧
// begineditorcommand();
//showwindow(sw_hide);
ads_name adsnameblockref;
ads_name entres;
ads_point ptres;
ads_matrix xformres;
struct resbuf *refstkres, *eb;
if(acednentselp(null,entres,ptres,false,xformres,&refstkres) == rtnorm)
{
for(eb = refstkres; eb != null;eb = eb->rbnext)
{
ads_name_set(eb->resval.rlname,adsnameblockref);
}
acutrelrb(refstkres);
// completeeditorcommand();
}
else
{
// canceleditorcommand();
}
//showwindow(sw_show);
acdbobjectid blkrefid;
acdbgetobjectid(blkrefid, adsnameblockref);
acdbblockreference *pblkref;
acdbopenobject(pblkref, blkrefid, acdb::kforread);

acdbobjectiterator *pattriter = pblkref->attributeiterator();
pblkref->close();
char *pstr = "";
char *ptext = "";
acdbattribute *pattr;
acdbobjectid attrobjid;
for(int attrnumber = 0; !pattriter->done(); pattriter->step())
{
attrobjid = pattriter->objectid();
acdbopenobject(pattr,attrobjid,acdb::kforread);
pstr = pattr->tag();
ptext = pattr->textstring();
pattr->close();
attrnumber++;
acutprintf("\nattribute %d,tag %s, value %s",attrnumber,pstr,ptext);
}
delete pattriter;


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